Happy New Years Eve!
I would like to be able to set the default for value some columns to descending. So, the first time the user clicks on that column, it sorts descending by nature.
I have no problem setting the default sort field and order of my grid. But that is all the info I am finding.
$grid->setGridOptions(array(
"caption"=>"Player Statistics",
"rowNum"=>200,
"rowList"=>array(50,200,1000),
"sortname"=>"percentOwned",
"sortorder" => 'desc',
"width" => 1000,
"height" => 400,
"hoverrows" => true,
"viewrecords" => false
));
How do I set the default sort to descending on a per column basis? Is it possible?
Thanks!
The Grid sorting logic is implemented in the jqxgrid.sort.js and you need to reference that javascript file. In the code example below, the Grid data sorting is enabled. To enable or disable the sorting of a Grid column, you can set its sortable property to false.
To remove the sorting, call the "removesort" function. When the data is sorted, the Grid raises the 'sort' event. By default, when the sorting is enabled and the user clicks a column's header, the sort order is changed.
To override the default sorting logic, you need to set the 'sort' member of the Grid's source object to a custom sorting function. The Grid will pass two parameters to this function - the sort column's datafield and the sort direction.
The Grid sorting logic is implemented in the jqxgrid.sort.js and you need to reference that javascript file. In the code example below, the Grid data sorting is enabled. To enable or disable the sorting of a Grid column, you can set its sortable property to false. In the code example below, the sorting of the "ShipName" column is disabled.
Although not in the documentation, 'firstsortorder' => 'desc' does the trick.
$grid->setGridOptions(array(
'firstsortorder' => 'desc'
"caption"=>"Player Statistics",
"rowNum"=>200,
"rowList"=>array(50,200,1000),
"sortname"=>"percentOwned",
"sortorder" => 'desc',
"width" => 1000,
"height" => 400,
"hoverrows" => true,
"viewrecords" => false
));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With