Damn it. I wasn’t even imagining that Zend team has done such a wonderful job for creating ajax enabled application. Last night I was amazed by dojo grid and today by combo box.
I don’t have words to appreciate Zend developers.
Lets see how much time and efforts it takes to make a fabulous ajax enabled combo box using dojo and zend framework.
Create a controller and place the following code
class TestController extends Zend_Controller_Action
$form= new Zend_Dojo_Form();
‘label’ => ‘ComboBox (datastore)’,
‘storeId’ => ‘stateStore’,
‘storeType’ => ‘dojo.data.ItemFileReadStore’,
‘storeParams’ => array(
‘url’ => ‘records’,
‘dijitParams’ => array(
‘searchAttr’ => ‘name’,
$sql = ‘SELECT * FROM company’;
$result = $db->fetchAll($sql);
$dojoData= new Zend_Dojo_Data(‘id’,$result,’id’);
We define our form as
$form = new Zend_Dojo_Form();
And combo box element to it. Few of it properties are important, such as storeId, storeType and storeParams. In the store Params we have given the url of the action.
Next we define our action which fetch data form the table and create Json response for us. That’s it we have done.
In view/scripts/index.phtml, only write
<? echo $this->form?>
Only one thing. Write following lines in your layout file
That’s it. You will now see a nice and beautiful combo box sending ajax request and fetching data on the fly.