I added an event that calls grid_load when setting up the grid.
If the status value is good I want the grid to be collapsed.
What is the call from within a script to collapse it.
<script>
function grid_load()
{
var grid = $('#list1');
var rowids = grid.getDataIDs();
var columnModels = grid.getGridParam().colModel;
var hidegrid = false;
// check each visible row
for (var i = 0; i < rowids.length; i++)
{
var rowid = rowids[i];
var data = grid.getRowData(rowid);
if (data.status == 'Good')
{
hidegrid = true;
break;
}
}
// the below are just guesses
if(hidegrid == true)
$('#list1').jqGrid('setGridState', 'hidden');
else
$('#list1').jqGrid('setGridState', 'visible');
}
</script>
Your code looks fine.
To test further, you can comment out everything except:
$('#list1').jqGrid('setGridState', 'hidden');
It will collapse on grid load.
If it is not working as expected, try some debugging by putting alert() statements and check if all variables data are fetched correctly.
Thanks Abu,
I was not calling it correctly.
It is working now.
I ended up putting it in
$agrid_options["loadComplete"] = "function grid_load() {…}"
$ogrid->set_options($agrid_options);
Will using loadComplete in this way cause any issues?
Glenn