Question

I am using Zend Framework that's why I decided to use "zfdatagrid deploy jqgrid" instead of using jqgrid straight away. I want to have jqgrid with subgrid. Grid is shown ok, but when I click expand button then I get notice "Loading" but nothing happens. I have debugged that "subGridUrl" is called correctly, because debugger hit function where I should select data from MySQL for subgrid, and I tried to pass pure json response (instead of selecting from MySQL) but still subgrid is not shown. Maybe I don't understand what response must be? My response:

<...>
$responce = new stdClass();
$responce->rows[0]['id']='0';
$responce->rows[0]['cell']=array('0','test1','123','1');
$responce->rows[1]['id']='1';
$responce->rows[1]['cell']=array('1','test2','321','2');
$j = json_encode($responce);
echo $j;
<...>
Was it helpful?

Solution

Sorry, my bad. But instead of deleting my question, I will explain my mistake incase somebody else will do the same...

I made a mistake declaring "subGridModel". Instead using array:

$jqGrid->setJqgParams(array(
    'caption' => 'test report',
    <..>
    'subGrid' => true,
    'subGridUrl' => $this->view->url(array('controller'=>'report','action'=>'indexstoragebalancesubgrid'),'default', true),
    'subgridtype' => 'json',
    'loadonce' => false,
    // next line where problem fixed
    'subGridModel' => array(array("name" => array("ID", "Title", "Code", "Quantity"), "width" => array(10,55,200,80)))
    <..>
));

I wrote string:

'subGridModel'=>'[{name : ["ID", "Title", "Code", "Quantity"], width : [10,55,200,80]}]'

And that's why it did not work in javascript.

By the way, you can see that I wrote array in array. That is because with one array ZFDataGrid generates such javascript:

"subGridModel":{"name":["ID","Title","Code","Quantity"],"width":[10,55,200,80]}

instead of this:

"subGridModel":[{"name":["ID","Title","Code","Quantity"],"width":[10,55,200,80]}]

It is important for jqgrid subgrid to work!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top