0
  1. How to do sorting in OnDemandGrid with JSONrestStore?

    I tried sortable:true like below but it did not work.

     {field: "column1",label: "column1",sortable:true},
     {field: "column2",label: "column1",sortable:true}
    

    The normal String sorting itself is not working.

  2. I also want to customize the sorting for currency fields and Date fields.

Please tell how to do customized sorting in OndemandGrid.

megawac
  • 10,953
  • 5
  • 40
  • 61
SSayee
  • 95
  • 4
  • 10

2 Answers2

0

If you're using the JsonRest store and you're sorting on a column you will notice that it's actually making request to the server, your sorting needs to happen server side (SQL query or whatever you're using) with the results passed back to the client.

C.N
  • 218
  • 1
  • 9
0

listen to the 'dgrid-sort' event on the onDemandGrid instance you have created to do any kind of custom sorting

myGrid.on('dgrid-sort', function(grid, parentEvent, data){
  // sort data according to your custom logic
}

You can also progrmatically set the sort order:

set("sort", property, descending)

Reference: https://github.com/SitePen/dgrid/wiki/Grid

bugs_cena
  • 495
  • 5
  • 11