2

我有一个 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>批号:&lt;/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代码:

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");
    });

我总是可以从服务器端获取数据,但有时数据不会被渲染。

4

1 回答 1

2

Quita la paginacion:

注意:分页扩展应该混合到 List 或 Grid 中,而不是 OnDemand 构造函数之一,因为它们包含自己的虚拟滚动逻辑。在内部,Pagination 继承自 OnDemand 原型所继承的同一个 _StoreMixin 模块,以便与 d​​ojo/store 进行通用集成。

https://github.com/SitePen/dgrid/wiki/Pagination

于 2014-02-13T19:34:26.900 回答