Stateful server side filtering in dojo

前端 未结 1 382
半阙折子戏
半阙折子戏 2021-01-27 18:35

I am doing server side filtering in the enhanced grid in dojo 1.10 version. Here in document it is clearly mentioned to use isStateful property. Also, if we use isStateful prope

相关标签:
1条回答
  • 2021-01-27 19:25
    require(['dojo/store/JsonRest',
            'gridx/Grid',
            'gridx/core/model/cache/Async',
            'gridx/modules/SingleSort',
            'gridx/modules/pagination/Pagination',
            'gridx/modules/CellWidget',
            'dijit/registry',
            'gridx/modules/Bar',
            'gridx/support/LinkPager',
            'gridx/support/Summary',
            'dojo/domReady!'],function(Store, Grid, Async, Sort, Pagination, CellWidget, registry, Bar, LinkPager, Summary){
        var jsonStore = new Store({
            idProperty: "id", target: <your url>,
                     query: function(query, options) {  
                         var request = {};              
                         /* Paging Params. */
                         if (grid==null) {   
                             /* null on first call to server. */
                             request.currentPage=0;
                             request.pageSize=DEFAULT_PAGE_SIZE;
                         } else {
                             request.currentPage=grid.pagination.currentPage();
                             request.pageSize=grid.pagination.pageSize();
                             if (request.pageSize==-1) {
                                 /* Page size is -1 when 'ALL' records selected. Reset */
                                  request.pageSize=DEFAULT_PAGE_SIZE;
                            }
                         }
                         /* Sorting Parameters. */
                         if (options.sort == null) {
                             /* null on first render. */
                             request.sortAttribute="id";
                             request.descending=false;
                         } else {
                            request.sortAttribute=options.sort[0].attribute;
                            request.descending=options.sort[0].descending;
                         }
                         var results = Store.prototype.query.call(this, request);   
                         return results;
                     }  
                 });
                 grid = new Grid({
                     cacheClass: Async,
                     store: jsonStore,
                     structure: <your column definition>,
                     barBottom: [{pluginClass: Summary, style: 'text-align: left;'},{pluginClass: LinkPager, style: 'text-align: right;'}],
                     modules:[Sort, Pagination, Bar, CellWidget]}); 
                 grid.pagination.setPageSize(DEFAULT_PAGE_SIZE);
                 registry.byId('gridDIV').set('content', grid);
                 grid.startup();
             });
    
    0 讨论(0)
提交回复
热议问题