Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
DataStore sort order ignored when DataGrid / DataTables columns are defined in the view
#427
Open Keith Burke
opened this topic on on Aug 22, 2018 - 9 comments
Keith Burke commented on Aug 22, 2018
I've noticed a problem with the DataTables object. If I define a subset of columns in the view, the sort order is ignored and set to ASC in column order.
For example, if I pipe in the following to my query
==
The sorting is ignored if I define columns in my view. Is there a nice way to resolve this?
Even sorting in the SQL and removing the sort pipe makes no difference.
Keith Burke commented on Aug 22, 2018
Sorry, I inserted the wrong [view] image but the scenario is the same. If I remove the defined columns in the view, the page shows ALL columns but the desired sorting is preserved.
Keith Burke commented on Aug 22, 2018
I've noticed that the sort order is honoured for about 1/4 of a second then over ridden somewhere as I see the proper sort order displayed them immediately changed.
KoolReport commented on Aug 22, 2018
DataTables has a client-side sorting mechanism so it could override it, could you please post again your full DataTables code here?
David Winterburn commented on Aug 23, 2018
Hi Keith,
By default, i.e with no ordering option set, DataTables widget orders the first column ascending. If you want to keep your data order in the datastore, please use either of these options:
Please let us know if this is what you want. Thanks!
Keith Burke commented on Aug 24, 2018
Nice one. 'ordering' => false resolved my issue. However, it also disabled clicking on the headers to sort reverse etc.
"order" => [], won't work for me, I think, as I'm sorting on columns that don't exist in the visible data set [sql sort]. Is it possible to hide columns in the DataGrid but sort by them using "order" => [], method, while maintaining the column sort feature?
Neither option worked for me. It always wants to sort on the first column. Code below:
<?php
require_once "../vendor/autoload.php";
$dname = "pass5b";
$x = "tblpass5bevent"; //"tbl" . $dname . "event";
$y = sprintf('"SELECT * FROM %s"', $x);
//echo $x;
use \koolreport\KoolReport;
use \koolreport\processes\Filter;
use \koolreport\processes\TimeBucket;
use \koolreport\processes\Group;
use \koolreport\processes\Limit;
//use \koolreport\clients\Bootstrap;
class TestReport extends \koolreport\KoolReport
{
//use \koolreport\clients\Bootstrap;
public function settings()
{
//Get default connection from config.php
$config = include "../config.php";
return array(
"dataSources"=>array(
"test_report"=>$config["query_source"]
)
);
}
protected function setup()
{
$this->src('test_report')
// "SELECT * FROM tblpass5bevent"
->query("SELECT * FROM tblpass5bevent ORDER BY 'localtestdate' DESC")
// ->query("SELECT * FROM $x")
// ->query($y)
->pipe($this->dataStore('test_by_day'));
}
};
?>
<?php
// use \koolreport\widgets\koolphp\Table;
use \koolreport\widgets\google\ColumnChart;
use \koolreport\datagrid\DataTables;
include '../functions.php';
If you feel that the supporter has done a good work,
you may send him some credit for his effort.
Any amount put into the tips box below is very appreciated!
We love you!