Hi,
I am evaluating jqGrid for a project that we are currently working on. The first task is to integrate jqSuite for PHP into a Zend Framework project. After some debugging this works.
However, I'm currently having the following problem: I'm using the following lines of code (in my Controller) to initialize jqGrid:
$this->_gridConn = new PDO(DB_DSN,DB_USER,DB_PASSWORD); $this->_grid = new jqGridRender($this->_gridConn); $this->_grid->SelectCommand = 'SELECT id, firma, vorname, nachname, telefon, plz, ort FROM b_kunden'; $this->_grid->table = 'b_kunden'; $this->_grid->dataType = 'json'; $this->_grid->setPrimaryKeyId('id'); $this->_grid->setColModel(); $this->_grid->setUrl('/kunden/fetchdata'); $this->_grid->setGridOptions(array( "rowNum"=>10, "rowList"=>array(10,20,30), "sortname"=>"id" )); $this->_grid->setColProperty('id', array("editoptions"=>array("readonly"=>true))); $this->_grid->navigator = true; $this->_grid->setNavOptions('navigator', array("excel"=>false,"add"=>true,"edit"=>true,"del"=>true,"view"=>true, "search"=>true)); $this->_grid->setNavOptions('edit',array("closeAfterEdit"=>true,"editCaption"=>"Update Customer","bSubmit"=>"Update")); $this->view->grid = $this->_grid;
The corresponding view simply renders the Grid:
<?php $this->grid->renderGrid('#grid','#pager',true, null, null, true,true); ?>
And last but not least, this Action returns the data:
$rows = array('0' => array('id' => '1', 'firma' => 'test', 'vorname' => 'Christian', 'nachname' => 'Meier', 'telefon' => '+43 699 66666666', 'plz' => '9020', 'ort' => 'Klagenfurt'),
'1' => array('id' => '21', 'firma' => 'test', 'vorname' => 'Andreas', 'nachname' => 'Dreier', 'telefon' => '+43 699 66666666', 'plz' => '9020', 'ort' => 'Klagenfurt'),
'2' => array('id' => '2', 'firma' => 'test', 'vorname' => 'Hubert', 'nachname' => 'Feier', 'telefon' => '+43 699 66666666', 'plz' => '9020', 'ort' => 'Klagenfurt'),
'3' => array('id' => '13', 'firma' => 'test', 'vorname' => 'Horst', 'nachname' => 'Heier', 'telefon' => '+43 699 66666666', 'plz' => '9020', 'ort' => 'Klagenfurt'));
$response['page'] = 1; $response['total'] = 1; $response['records'] = 3; $i=0; foreach ($rows as $r) { $response['rows'][$i]['id']=$r['id']; //id $response['rows'][$i]['cell']=array($r['id'],$r['firma'],$r['vorname'],$r['nachname'],$r['telefon'],$r['plz'],$r['ort']); $i++; } echo Zend_Json::encode($response);
The problem is, that this renders something like:
As you can see, the ID is displayed but all the other data is missing (i.e. not rendered). Any help or hint would be appreciated very much!
Thanks
Christian