Hello,
is there a way to hide or not show the grid when there are no rows?
Scenario:
there's 2 grids on one page and user will select a row from table 1. That row will appear on table 2. However, at the beginning, table 2 will be empty so I want to hide it for a cleaner ui and less confusing.
Thanks
W
If you are using master detail grid,
1) Set detail grid in a div with display none: e.g.
<div id="grid2" style="display:none">$out2</div>
2) you can set following in master grid options:
$opt["onSelectRow"] = "function(){ $('#grid2').show(); }";
The detail grid will be initially hidden and when you select row of master grid, it will show that div.
is there php code that I can check if the query returned any rows:
$g->select_command = "SELECT *
FROM invoices where id = $id;
is there a $g["rowcount"] to check?
Thanks.
It's not doable with PHP. Grid generates the structure (toolbar etc) no first request, and load data on second ajax request.
Instead of master grid 'onSelectRow' you can connect event on list2 loadComplete,
e.g.
$opt["loadComplete"] = "function(){ if (jQuery('#list2').jqGrid('getGridParam','records') > 0) $('#grid2_div').show(); }";
Hello,
The above JS code was just to give an idea.
I've not executed it. You need to debug yourself.
If you still think it is not workable, please send me your implementation along with screenshot for review at [email protected]