|
satish
|
 |
« on: March 11, 2008, 12:19:46 AM » |
|
Hello Everyone,
We are facing another problem for sorting the numeric columns. The following script we are using for grid columns and columns are associates with database fields.
var context = { sequence:false,checkBox:false,readonly:<?php echo $sigma_readonly?>,locked:1,sortable:false
};
var columns = [
{name:"DESCRIPTION",caption:"Authorized Products Description",width:310,mode:"string",sortable:true,readonly:true}, {name:"SHELF_STOCK_DAYS",caption:"Shelf ",sortable:true,children:[ {name:"SHELF_STOCK_DAYS",caption:"Stock",width:60,mode:"number",format:"#", align:"center",sortable:true}]}, {name:"SHELF_STOCK_DATE",caption:"Shelf Date",sortable:true,children:[{name:"SHELF_STOCK_DATE", caption:"(mm/dd/yyyy)",width:90, align:"center",mode:"date", render:dateRender,align:"center",editor:dateEditor,sortable:true}]}, {name:"PRICE",caption:"Price",width:60,mode:"number",format:"#.#0",sortable:true}, {name:"SPACING",caption:"Spacing",width:95,mode:"select",sortable:true, options:[ {id:"1st Shelf",name:"1st Shelf"}, {id:"2nd Shelf",name:"2nd Shelf"}, {id:"3rd Shelf",name:"3rd Shelf"}, {id:"Top",name:"Top"}, {id:"Well",name:"Well"}, {id:"No Slot",name:"No Slot"}]}, {name:"ROWS",caption:"Rows",width:60,mode:"select",sortable:true, options:[ {id:"0",name:"0"}, {id:"1",name:"1"}, {id:"2",name:"2"}, {id:"3",name:"3"}, {id:"4",name:"4"}]}, {name:"BACKROOM_STOCK_DAYS",caption:"Backroom ",width:60,mode:"number",format:"#",sortable:true,children:[ {name:"BACKROOM_STOCK_DAYS",caption:"Stock",width:65,align:"center", sortable:true,mode:"string"}]}, {name:"BACKROOM_STOCK_DATE",caption:"Backroom Date",sortable:true,children:[{name:"BACKROOM_STOCK_DATE", caption:"(mm/dd/yyyy)",width:100, align:"center",mode:"date", render:dateRender,align:"center",editor:dateEditor,sortable:true}]} ];
grid = new SigmaGrid("gridbox",context,columns); grid.bindData([]);
The problem is it is not sorting numeric columns properly. when we defined data into array and tested. it sorted numeric columns(hardcoded array's values). It is only giving problem when we fetch data from database tables and get it into xml and bind the grid.
e.g. In price column we put the following values :
150 20 90 600 10 110
After entering all values when we click on price column for sorting, it will sort the values like below :
10 110 150 20 600 90
It consider values as string and sort it.. NOTE : values are comming from database in xml format.
Please comment..
Thanks
|