Hi Abu,
I would like to change the grid's $ogrid->select_command sql on the fly.
I created a button on the toolbar that can refresh the grid, but need a way to change the sql before it is refreshed.
jQuery('#list1').trigger('reloadGrid',[{page:1}]);
Thanks Glenn
Just to give an idea,
You can pass extra param e.g. 'sql' with some value e.g. 'query1' and put IF condition on select_command statements.
jQuery('#list1').setGridParam({ postData: { sql: 'query1' } }).trigger('reloadGrid');
There is a limitation that you cannot change the # of columns and other column settings with this. As reloadGrid is ajax call, only loading data will be affected.
Thank Abu,
How would I access that param?
What would that if statement look like?
Thanks
Glenn
it would be something like:
if ($_POST["sql"] == "query1")
$g->select_command = "…";
else if ($_POST["sql"] == "query2")
$g->select_command = "…";
Thanks Abu,
I tried but could not seem to get it working.
I modified alternate-row with a button called ShowAll.
http://www.websalesdesign.com/proj/lib/phpgrid-full/index.php
http://www.websalesdesign.com/proj/lib/phpgrid-full/demos/appearence/alternate-row.php
What did I miss?
Thanks
Glenn
I just checked it, the extra param is passed in $_GET not in $_POST.
So you need to change it to:
if ($_GET["sql"] !== "ALL")
$qry = $qry . " where name like '%posts'";