Sorting columns in the DHTML Grid


Could you please let me know, how to sort dates in a column in descending order(recent date firt) by default. i.e. the grid needs to sorted based on the date and the date should be sorted in descending order by default.

Thanks in advance for you help.

1. Necessary columns should have “calendar”, “dhxCalendar” or “dhxCalendarA” type

2. Set “date” sorting type with method mygrid.setColSorting(“str,date,date”);

3. After grid was loaded call sortRows method


sortRows(col, type, order):

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

Also if you want to show sorting image add setSortImgState method after calling sortRows.

setSortImgState(state, ind, order, row): state - true/false - show/hide image, ind - index of field, order - asc/desc - type of image, row - one based index of header row ( used in multirow headers, top row by default )