I have a grid that I created using the jqGrid PHP API and the Choose Columns add-on (to show/hide columns). I need to add the ability to save the grid state (after doing any filtering, altering the column order or hiding any columns).
I've seen several posts that use either cookies or a localStore to save the state of the grid. However, I want to be able to save it in a database so that I can restore it later, the next time the user logs into the system.
Here's the PHP code I have for the grid:
require_once JQGRID_PATH."php/jqGrid.php";
require_once JQGRID_PATH."php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASS);
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
$grid->SelectCommand = 'SELECT timestamp, user_name, action_type FROM audit_log';
// set the ouput format to json
$grid->dataType = 'json';
// Let the grid create the model
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl('audit_log');
// Set grid caption using the option caption
$grid->setGridOptions(array(
"caption"=>"Audit Log Report",
"height"=>470,
"width" => 1100,
"rowNum"=>25,
"shrinkToFit"=>false,
"sortname"=>"timestamp",
"sortorder"=>"desc",
"rowList"=>array(25,50,100)
));
$grid->navigator = true;
$grid->setNavOptions(
'navigator', array(
"excel"=>true,
"add"=>false,
"edit"=>false,
"view"=>false,
"del"=>false,
"pdf"=>true
)
);
$grid->renderGrid('#grid','#pager', true, null, null, true, true, true);
Also, the posts that I've seen that use localStore to save the grid state are all built using jQuery and not the jqGrid PHP Suite. Any ideas on how I can accomplish this with the jqGrid PHP API?
Any help would be greatly appreciated.
Thanks!