Help my grid’s remote sorting (remoteSort:true) is not working after moving to Extjs 4

来源:互联网 发布:淘宝厚底鞋 编辑:程序博客网 时间:2024/06/01 19:14

It’s always the little things that seem to catch you by surprise! Here’s a new one that may pop up when migrating your application from extjs3 to extjs4, and it has to do with server side behavior, so it will not be apparent on the front end. It looks like remote sort which used to pass the parameters ‘sort’ and ‘dir’ to the server has been changed to pass the parameters in an array object with the name ‘sort’ just like this instead:

1[{"property":"field_name","direction":"ASC"}]

If you would like to change the sort call to the same format as Extjs 3 in order to transfer your applications just set the following parameter, simpleSortMode:true, in the proxy of the store and it will revert to the ‘old’ way of passing the parameters.
My sample remotely sorted store

01Remote_sort_store_example = new Ext.data.Store({
02    model: ‘Remote_sort_store_’,
03    remoteSort:true,
04    pageSize:50,
05    proxy: {
06      type: 'ajax',
07      actionMethods: {
08        create : 'POST',
09        read   : 'POST',
10        update : 'POST',
11        destroy: 'POST'
12      },
13      simpleSortMode:true,     
14      url: 'learnsomethings.com/somethings/',
15      reader: {
16        type: 'json',
17        root: 'data',
18        totalProperty: 'results'
19      }
20    },
21    autoLoad: false
22  });
From:http://www.learnsomethings.com/2011/05/27/help-my-grid%E2%80%99s-remote-sorting-remotesorttrue-is-not-working-after-moving-to-extjs-4/
原创粉丝点击