我有一个dgrid,并使用JsonRest从服务器端获取数据。我按了一个按钮来过滤数据。 这是html代码:
<div data-dojo-type="dijit/TitlePane" title="<b>查询</b>">
<div class="row-fluid">
<div class="span12">
<div class="row-fluid">
<div class="span10 offset1">
<table>
<tr>
<td>批号:</td>
<td><input id="simple_store_dgrid_search_batch_no"
style="width: 120px; height: 20px"
data-dojo-type="dijit/form/TextBox" /></td>
</tr>
</table>
</div>
</div>
<div class="row-fluid">
<div class="span6 offset6">
<button type="button" id="simple_store_dgrid_clear_button">清除</button>
<button type="button" id="simple_store_dgrid_search_button">查询</button>
</div>
</div>
</div>
</div>
</div>
<div id="simple_store_dgrid_table_toolbar"></div>
<div id="simple_store_dgrid_table"></div>
js code:
require([ "dgrid/OnDemandGrid", "dgrid/Selection", "dgrid/Keyboard", "dojo/_base/declare",
"dojo/store/JsonRest", "dojo/store/Observable", "dgrid/extensions/Pagination",
"dijit/Toolbar", "dijit/form/Button", 'dojo/query', "dijit/registry", "dojo/domReady!" ],
function(Grid, Selection, Keyboard, declare, JsonRest, Observable, Pagination, Toolbar,
Button, query, registry) {
**var jsonRest = JsonRest({
target : "../rest/dGrid/",
idProperty : "batchId"
});
var store = Observable(jsonRest);**
var columns = [ {
label : '批号',
field : 'batchId',
sortable : true
}, {
label : '创建日期',
field : 'creationDate',
sortable : true
}, {
label : '创建人',
field : 'createdBy',
sortable : true
}, {
label : '描述',
field : 'description',
sortable : true
} ];
**var grid = new (declare([ Grid, Selection, Keyboard, Pagination ]))({
store : store,
getBeforePut : false,
columns : columns,
minRowsPerPage : 10,
pagingLinks : 1,
loadingMessage : '数据加载...',
selectionMode : "single",
noDataMessage : '没有查到数据'
}, "simple_store_dgrid_table");
grid.startup();**
var toolbar = new Toolbar({}, "simple_store_dgrid_table_toolbar");
var clear = new Button({
onClick : function() {
var batch_no = registry.byId("simple_store_dgrid_search_batch_no");
batch_no.set('value', '');
}
}, "simple_store_dgrid_clear_button");
var search = new Button({
onClick : function() {
**var batch_no = registry.byId("simple_store_dgrid_search_batch_no");
grid.set("query", {
batch_no : batch_no.get('value')
});**
}
}, "simple_store_dgrid_search_button");
});
我总是可以从服务器端获取数据,但有时数据不会被渲染。
答案 0 :(得分:2)
Quita la paginacion:
注意:Pagination扩展应混合到List或Grid中,而不是其中一个OnDemand构造函数,因为它们包含自己的虚拟滚动逻辑。在内部,Pagination继承自OnDemand原型继承的相同_StoreMixin模块,用于与dojo / store的通用集成。