Monday, June 30, 2014

Custom Sorting in a Dojo Grid using ItemFileRead/Write store

First understand the below example to see how to plug a grid to a store. 

Then to sort alphabetically, based on locale use the code below 

              queryGrid.setStore(new dojo.data.ItemFileReadStore(response[responseResult]));  
              setCustomSort(queryGrid.store); 
 
Define the sort function as below :       
 
              function setCustomSort(store){
                               if(!store.comparatorMap){
                                       store.comparatorMap = {};
                              }
                              store.comparatorMap["name"] = function (a, b) { 
                              return a.localeCompare(b);
                     }  

No comments:

Post a Comment