2009年8月25日星期二

Re: [fw-mvc] Fetch data to Json conversion issue

fetchAll will return an Zend_Db_Table_Rowset_Abstract object. This object, store "data" in a "protected" propertie ($_data), so, json_encoding an object will encode the "PUBLIC" properties of an object. I think you can use toArray() method  to obtain the data as an array. Try this:


public function gettaskAction()
      {
            $taskhead new Taskhead();
            $data$taskhead->fetchAll();
            $arr array (identifier=>'name',
                  items=>array(
                  array('name'=>'Bidding''label'=>'Bidding'),
                  array('name'=>'Response-proposal    ''label'=>'Response-proposal')
               )
            );
            $this->_helper->json($data->toArray()array('enableJsonExprFinder' => true));          
      }

Zend_Db_Table_Rowset_Abstrac

El 25/08/2009, a las 14:41, Naimesh.Trivedi (Gmail) escribió:

Dear Sir,
 
 
Hello ! Well I am calling ajax request from my javascript function which in turn is called from dojo.combobox onChange event. I want to return Json output to this javascript from my action. It works well on hard coded array $arr but does not work with $data which has actual dynamic table data.
 
 
      public function gettaskAction()
      {
            $taskhead = new Taskhead();
            $data= $taskhead->fetchAll();
            $arr = array (identifier=>'name',
                  items=>array(
                  array('name'=>'Bidding', 'label'=>'Bidding'),
                  array('name'=>'Response-proposal    ', 'label'=>'Response-proposal')
               )
            );
            $this->_helper->json($data, array('enableJsonExprFinder' => true));          
      }
 
If I put above $arr in place of $data in json call, it works well and populate my comboxbox but putting $data it does not work, might be not proper json format is converted.
 
Please guide me on this.
 
Thanks in Advance !
 
Naimesh
 
 

没有评论: