zig2na wrote:
> 
> Im using Zend_Dojo_Data and in a controller for my datasource but it still
> can't filter, Im sure having issues with the onchange
> 'dojo.data.ItemFileReadStore ' url. Is possible to break the onchange url
> down me, that only seems to be the problem now. Thanks
> 

The onChange url needs to send back a Json-encoded response- basically an
array of rows containing name-value pairs passed to Zend_Json_Encoder.

In my "data" controller I have a generic "lookup" action.  All you need is a
model that can return rows of city names and id's.

        public function lookupAction()
        {
                $tableName = $this->_request->getParam('table');
                $filterName = $this->_request->getParam('filterName');
                $filterValue = $this->_request->getParam('filterValue');
                
                if (empty($tableName))
                {
                        return;
                }
                
// TODO:  Should be generic for all lookup tables
                if ('city' === $tableName) {
                        $_model = new NAME_OF_YOUR_CITY_MODEL();
// getLookup just returns the rows that match the filter, in this case a
countryId
                        $data = $_model->getLookup($filterName, $filterValue);  
        
                
                        if (null !== $data) {
                        $items = array();
                            foreach ($data as $row) {
                                $items[] = array('label' => $row->name, 'name' 
=> $row->name,
'key' => $row->cityId);
                        }
                $final = array(
                        'identifier' => 'key',
                        'items' => $items,
                        );
                echo Zend_Json_Encoder::encode($final);
                        }
                }
        }
-- 
View this message in context: 
http://old.nabble.com/How-to%3A--Zend-Dojo-Form-Dependent-Selects-%28e.g.-Country-City%29-tp25269984p26267204.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to