Get KoolPHP UI with 30% OFF!

Fetch sorted data from grid and put into an array

Shaun
Hi :)
Is there a way to fetch the sorted data from a grid and put into an array. I want to use it to dynamically update a chart based on the sorted data.
Shaun
Posted Sep 2, 2015 Kool
Peter
You can get the row data from Grid but only within single page. If you want to get the whole data, you need to catch the OnColumnSort server-side event, you will get what column is sorted. You save those sorting data into $_SESSION. Later on, if there is request to get data to build charts, you rebuild the SELECT statement with the information of sorting and push the data to charts.
Posted Sep 2, 2015 Kool
Shaun
OK, I got you. It will be quite a mission for me because I'm populating the grid with an array so I would have to filter the array to reflect the result of the column sorts which I'm not keen to take a day to figure out right now :)
Posted Sep 2, 2015 Kool
Shaun
would it be the same scenario if I wanted to total up the values in a column and insert the total into the columns footer ?
Posted Sep 2, 2015 Kool
Abraham
Hi there Shaun. to have totals displayed on the Footers all you need is:
<?php				
...	
	$col = new GridBoundColumn();//GridBoundColumn is inherited from GridColumn
	$col->FooterText = "Total Sum: ";
	$col->Aggregate = "Sum";
	$grid->MasterTable->AddColumn($col);
...
?>

Hope this helps.
Posted Sep 2, 2015 , edited Sep 2, 2015 Kool -
Shaun
thanks Abraham
that's nice and easy. :)
Posted Sep 3, 2015 Kool
Shaun
thanks Abraham
that's nice and easy. :)
Posted Sep 3, 2015 Kool
Abraham
You are welcome :).
Posted Sep 3, 2015 Kool
HJ
Put sorted/filtered data into an array:
$grid->Process();

//$grid->KeepViewSessionInState=true;
$dataArray=array();
$dataArray=$ds->GetData();
$_SESSION["tablerows"]=$dataArray;
After $grid->Process(): Filtered/Sorted data, before $grid->Process(): All data. Tested with Koolgrid version 5.1.0.0
Posted Nov 13, 2015 Kool