Get KoolPHP UI with 30% OFF!

Sorting multiple columns

Karl Higeli
Hi I can't seem to get sorting by more than one field at one time.
What am I doing wrong ? I tried ..
AllowFiltering = true;
$grid->SingleColumnSorting = false;
I tried every combination I could think of, but nothing seems to work.
Here is my code ...
$ds = new AdvancedArrayDataSource($arr);
$grid = new KoolGrid("grid");
$grid->scriptFolder = $KoolControlsFolder."/KoolGrid";
$grid->styleFolder="Default";
$grid->Width = "938px";
$grid->DataSource = $ds;
$grid->AjaxEnabled = true;
$grid->AllowSorting = true;
$grid->PageSize = 10;
$grid->AjaxLoadingImage = $KoolControlsFolder."/KoolAjax/loading/5.gif";
$column = new GridBoundColumn();
$column->DataField = "Department";
$column->HeaderText = "Department";
$column->AllowSorting = true;
$column->AllowFiltering = true;
$grid->MasterTable->AddColumn($column);
$column = new GridBoundColumn();
$column->DataField = "Name";
$column->HeaderText = "Name";
$column->AllowSorting = true;
$column->AllowFiltering = true;
$grid->MasterTable->AddColumn($column);
$column = new GridBoundColumn();
$column->DataField = "DepAirport";
$column->HeaderText = "From";
$column->AllowSorting = true;
$column->AllowFiltering = true;
$grid->MasterTable->AddColumn($column);
$column = new GridBoundColumn();
$column->DataField = "Airport";
$column->HeaderText = "To";
$column->AllowSorting = true;
$column->AllowFiltering = true;
$grid->MasterTable->AddColumn($column);
$column = new GridBoundColumn();
$column->DataField = "Carrier";
$column->HeaderText = "Carrier";
$column->AllowSorting = true;
$column->AllowFiltering = true;
$grid->MasterTable->AddColumn($column);
$column = new GridBoundColumn();
$column->DataField = "Flight";
$column->HeaderText = "Flight";
$column->AllowSorting = false;
$grid->MasterTable->AddColumn($column);
$column = new GridBoundColumn();
$column->DataField = "Locator";
$column->HeaderText = "Locator";
$column->AllowSorting = false;
$grid->MasterTable->AddColumn($column);
$column = new GridBoundColumn();
$column->DataField = "CountryName";
$column->HeaderText = "Country";
$column->AllowSorting = true;
$column->AllowFiltering = true;
$grid->MasterTable->AddColumn($column);
$grid->AjaxEnabled = true;
$grid->AllowGrouping = true; //Allow Grouping
$grid->MasterTable->ShowGroupPanel = true; //Show Group Panel
$grid->MasterTable->Pager = new GridPrevNextAndNumericPager();
Posted Aug 30, 2015 Kool -
David
Hi Karl,
KoolGrid allows multiple sorts by default. Please go to our online demo to check:
Grid sorting
Would you please explain more cleary what did not work for you? A screenshot would be appreciated.
Rgds,
Posted Aug 31, 2015 Kool
Karl Higeli
David,
Thanks for your response.
I am attaching a screenshot.
In this example (I have limited the view to make it easier to understand). I have selected FROM which has sorted alphabetically, now I also want to sort by Carrier and as you can see, although I have selected it, Carrier is not sorted.
It appears that the logic works right to left. If I sort a column on the right and then afterwards sort a column to it's left, it will sort the column on the left and ignore the first column.
Please let me know if I am missing something.
Regards ... Karl
Posted Aug 31, 2015 Kool
David
Hi Karl,
You got the current sorting logic correctly. In multi sorting, the grid is sorted from left to right in term of high to low priority regardless of the order of clicking. So to change the priority of sorting you would have to change the order of the columns.
We could consider the idea of setting sorting order by clicking in the future or you could suggest other kinds of setting order.
Rgds,
Posted Sep 1, 2015 , edited Sep 1, 2015 Kool -
Karl Higeli
David,
Thanks again for getting back to me.
Changing the order of the columns isn't really a solution for me, or I suspect for many others. If I knew what my end user was going to need, then I would simply sort the results ahead of time and present it in the grid without the ability to sort. However, the power of the grid, in my opinion is the ability for the end user to manipulate the data within the grid. The grouping and filtering demonstrate this quite well. However, ideally, being able to sort in various ways is equally as important.
Ideally, the end user should be able to sort the data depending on their specific need (which will vary). I would love to see a number appear (red) beside the sort control indicating the sort priority in the column header. This would tell the user visually what the sort order is. I suppose the only practical way to determine priority would be based on selection order. The user would have to deselect a sort if he wanted to change the order. Any other way would entail dropdown selections etc. which could get messy.
The above change would, in my view, make the grid control a perfect tool for so many uses.
I appreciate the response and the consideration.
Regards … Karl
Posted Sep 1, 2015 Kool -
David
Thanks, Karl, for your suggestion. We definitely would consider your point in future releases of KoolGrid. Hope a solution can be found soon.
Rgds,
Posted Sep 3, 2015 Kool