Sigma Php Ajax framework, Ajax Components, GUI Builder
February 11, 2012, 08:05:43 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Sigma Grid Numeric column sorting problem  (Read 1338 times)
satish
Jr. Member
**
Posts: 14


View Profile
« 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

Logged
stani
Jr. Member
**
Posts: 14


View Profile
« Reply #1 on: February 06, 2009, 03:28:29 AM »

var dsOption= {

   fields :[
      {name : 'oiltype_name' },
      {name : 'vi',type:'int' }]
}



If you set the field type as int, then the sorting works..........
Logged
jel0
Newbie
*
Posts: 3


View Profile
« Reply #2 on: August 12, 2010, 06:50:45 PM »

var dsOption= {

   fields :[
      {name : 'oiltype_name' },
      {name : 'vi',type:'int' }]
}



If you set the field type as int, then the sorting works..........

this does work if the values are int. But thing is with strings the same problem is still there.

let's say we have the following string values in a column:
name11
name12
name13
name2
name3

in ascending order, instead of it appearing as:
name2
name3
name11
name12
name13

it still show as that of the first example.

is there a workaround for this?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!