Categories | Question details Back To List | ||||||||
DHTMLX Grid : Sorting of column which can contain combination of String and integer. Hi, I have a query that if my grid's column is containing data like "S103850" then how to sort it ?????? Answer posted by Support on Jul 30, 2008 05:22 If you want to sort them by numeric part it can be done by using custom sorting functionality http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Sorting_in_grid.html#grid_art_sort function custom=function(a,b,order){ a=parseInt(a.toString().substr(0)); b=parseInt(b.toString().substr(0)); return (a>b?1:-1)*(order=="asc"?1:-1); } grid.setColSorting("custom"); Answer posted by Tejas Shah on Jul 30, 2008 06:37 Will this work for all columns or for A PARTICULAR column ??? I want to have it for certain columns only. Answer posted by Support on Jul 30, 2008 10:05 The setColSroting command assigns sorting types to columns of grid, so you can assing necessary types to necessary columns grid.setColSorting("str,custom,str,str"); In such case only second column will have custom sorting functionality. Answer posted by Tejas Shah on Jul 31, 2008 05:41 Hi, But suppose I have a column that can contain characters and integers in any order, then how to sort it ???? Please help. Thanks in advance. Answer posted by Support on Jul 31, 2008 08:38 The default sorting type str will sort all values as strings , which will work for any type of value. By using custom sorting you can implement any sorting rule, I'm not sure which result you expect for sorting such mixed value. Answer posted by Tejas Shah on Aug 01, 2008 02:29 Hi, Suppose I have values like in a column: AB43534543 546656aadsa @#ffdgf54354 esdadsadsdsd 213213321 According to our requirements, it should first show @#ffdgf54354 213213321 546656aadsa AB43534543 esdadsadsdsd then how to achieve it ??? Please help. Answer posted by Support on Aug 01, 2008 05:17 Default "str" rule will work very similar to your case Attachments (1)
|