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,
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 behaviors = sender.get_behaviors();
if (!behaviors) return;
var sorting = behaviors.get_sorting();
if (!sorting) return;
var sortedColumns = sorting.get_sortedColumns();
var index = getSortedIndexFromColumnKey(sortedColumns, "ColumnKey");
Hope this helps!
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
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.
Thanks
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,
Thanks for reply. But that wont fix my problem. Check this scenario, Suppose if a user want to sort multiple columns he have to use ctrl key. But if he sorting only one column after then the previous sorted columns will not be in sorted mode. So before the sorting occurs I want to find out is he is going to sort a column with another column or just a column alone? Then how should I find it before sorting occurs??
Needs a quick solution. Please provide one as soon as possible.