我有一个带有 JsonRestStore 绑定到后端 Rest API 的 EnhancedGrid。这就是我的代码:
<script>
/**
* Creates Dojo Store.
*/
require(["dojo/store/JsonRest"], function (JsonRest) {
myStore = new JsonRest({ handleAs: 'json', target:
'https://api.twitter.com/1/statuses/user_timeline.json'+
'?trim_user=true&screen_name=twitter&count=100' });
});
var layout = [[
{ name: 'Created at', field: 'created_at', datatype: 'string',
width: '100px' },
{ name: 'Message', field: 'text', datatype: 'string',
width: 'auto', autoComplete: true },
{ name: 'Source', field: 'source', datatype: 'string',
width: '200px', filterable: false },
{ name: 'Retweets', field: 'retweet_count', datatype: 'number',
width: '100px', disabledConditions: ["startsWith", "notStartsWith"] }
]];
/**
* Creates Dojo EnhancedGrid.
*/
require(["dojox/grid/DataGrid",
"dojox/grid/EnhancedGrid",
"dojo/data/ObjectStore",
"dojox/grid/enhanced/plugins/Filter",
"dojox/grid/enhanced/plugins/NestedSorting",
"dojox/grid/enhanced/plugins/Pagination",
"dojo/domReady!"
], function (DataGrid, EnhancedGrid, ObjectStore) {
var grid = new EnhancedGrid({
id: 'grid',
store: dataStore = new ObjectStore({ objectStore: myStore }),
structure: layout,
//clientSort: "true",
rowsPerPage: 5,
rowSelector: "20px",
selectionMode: "single",
plugins: {
filter: {
ruleCount: 5,
itemsName: "Tweets"
},
nestedSorting: true,
pagination: {}
}
});
grid.placeAt('grid5');
grid.startup();
});
</script>
<div id="grid5"></div>
如您所见,我为我的网格使用了几个插件。过滤器插件工作正常。为此,我只使用客户端过滤。但是插件分页和嵌套排序不起作用。
排序:单击箭头“asc”或“desc”不会更改顺序。分页:导航到接下来的 25 个条目仍然包含与之前的页面相同的 25 个条目。
对于这两个插件,点击后似乎只是从后端加载新的 json 并再次呈现。网络流量也表明了这一点。有没有办法让它在客户端工作?