Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Manoj on Jun 05, 2009 04:57
open dhtmlx forum
Sorting to be done based on different header

Hi All,

Im using this grid for long time

Now I have a strange requirement from my client

My Grid basicaly have four coloumn

when ever he clicks for sorting in the 1st coloum it should be sorted based on the 4th coloumn.

Basicly when ever my column_index is 0 can I say column_index =4 .

I had tried this but not working
Answer posted by dhxSupport on Jun 05, 2009 05:04
To change default sorting behaviour you can use "onBeforeSorting" event. This event occurs before starting data sorting. Event handler has parameters:
*column index
*sorting type (“str”,”int”,”date”)
*direction of sorting (“asc”,”des”)

grid.attachEvent("onBeforeSorting", function(ind,type,direction){
  grid.sortRows(4,type,direction);
  return false;
  });
sortRows(col, type, order) method has parameters: 
col - index of column, by which grid need to be sorted
type - sorting type (str,int,date), optional, by default sorting type taken from column setting
order - sorting order (asc,des), optional, by default sorting order based on previous sorting operation