Hi Team,
As I had implemented some additional functionalities, I need to check whether the ctrl key is pressed for multi sort so that I can determine the sort direction. So will it able to track down the ctrl key press event inside the client event "wdg_ColumnSorting(sender,e)". If so how can I achieve it in script inside thw wdg_ColumnSorting client side function.
i.e; in short I want to check that its multi sorting is happening (or ctrl key is pressed while its occurence) inside wdg_ColumnSorting client side function.
Any help in this direction will be highly appreciated. Hopes it is possible and expecting a reply in soon for this.
Please provide a reply as soon as possible.
Thanks & Regards,
Assyst
Hello Assyst,
It is possible to recognize directly the sorting mode. You do not need to check for the ctrl key. Here is how:
Subscribe to the client column soring event like this
<ig:Sorting SortingMode="Multi" SortingClientEvents-ColumnSorting="onColumnSorting"/>
function onColumnSorting(sender, e) {
var behaviors = sender.get_behaviors();
if (!behaviors) return;
var sorting = behaviors.get_sorting();
if (!sorting) return;
var sortingMode = sorting.get_sortingMode();
//sortingMode == 0 => single
//sortingMode == 1 => multi
}
Ivan,
I want to check whether he is going for a multi sort (keeping the sorted ones there while sorting) or a new single column sort? How it can be checked?
Regards,
You can use
sorting.get_sortedColumns() to indentify currently sorted columns;
e.get_column() to identify which column is being sorted
e.get_clear() to identify if already sorted columns will be removed or not before sorting the current column.
Hope this helps!
Thanks
Ivan
Hi Ivan,
e.get_clear() was what I want. I thought it was for some other functionality. Anyway that make the work around.
I had one more question. How can we retrieve the sorted index of a column?
For example if we sort 2nd column at first it's index on sortedcolumns collection will be 0 and with that if we sort 1st column then it's index on sortedcolumns collection will be 1. So how can we retrieve this index (sorted index) in script?
This too needed to complete the functionality. Hopes a reply in soon.
Thanks in advance.
You can use the unique key of the column to solve the task.
So, first attach to SortingClientEvents-ColumnSorted="onColumnSorted" event in the markup of the grid and implement as following:
function getSortedIndexFromColumnKey (sortedColumns, columnKey)
{
if (!sortedColumns) return -1;
if (!columnKey) return -1;
for (var i = 0; i < sortedColumns.length; i++)
if (sortedColumns[i].get_key() == columnKey)
return i;
return -1;
function onColumnSorted(sender, e)
var sortedColumns = sorting.get_sortedColumns();
var index = getSortedIndexFromColumnKey(sortedColumns, "ColumnKey");