【问题标题】:Dojox datagrid with QueryReadStore virtual pagining issue带有 QueryReadStore 虚拟分页问题的 Dojox 数据网格
【发布时间】:2012-12-27 11:30:29
【问题描述】:

我正在使用 dojox.grid.DataGrid 和 dojox.data.QueryReadStore。我在客户端有以下代码:

var store = new dojox.data.QueryReadStore({url:"<?php echo $this->url(array("action"=>"load-plans")) ?>"});
    //var store = new dojo.data.ItemFileWriteStore({url:"<?php echo $this->url(array("action"=>"load-plans")) ?>"});
    /*set up layout*/
    var layout = [[
            {name: 'Plan Name', field: 'title', width: '100px'},
            {name: 'User', field: 'email', width: '150px',get: formatEmail},
            {name: 'Status', field: 'percentage_completed', width: '100px'},
            {name: 'Word Count', field: 'word_count', width: '50px'},
            {name: 'Revenue Entries', field: 'revenue_count', width: '50px'},
            {name: 'Expense Entries', field: 'expense_count', width: '50px'},
            {name: 'Fund Entries', field: 'funds_count', width: '60px'},
            {name: 'Total Profit', field: 'total_profit', width: '60px'},
            {name: 'Total Funding', field: 'total_funding', width: '60px'},
            {name: 'Template Used', field: 'template_title', width: '100px'},
            {name: 'Last modified', field: 'updated_at', width: '100px'},

    ]];

    /*create a new grid:*/
    grid = new dojox.grid.DataGrid({
        id: 'plan-grid',
        store: store,
        structure: layout,
        escapeHTMLInData: false
        },

在服务器端: $data = $availableMerchants->getList($sort, $order, $start, $limit)->toArray();

    $dojoData = new Zend_Dojo_Data('id', $data, 'id');
    $this->getResponse()->setHeader('Content-Range', "items $start-$limit/302");
    echo $dojoData->toJson();

但是当我滚动虚拟分页时,它不起作用。它只发出 start=0&count=25 的第一个请求,不会发出进一步的请求。

请帮忙。

【问题讨论】:

    标签: zend-framework dojox.grid.datagrid dojo


    【解决方案1】:

    据我所知,对于 QueryReadStore,您需要有类似的响应,

    {
       "items":[list of items],
       "identifier":"id",
       "numRows": <total no of rows>
    }
    

    因此,无需在响应标头中设置项目数。您的 JSON 响应应采用上述格式。

    【讨论】:

      猜你喜欢
      • 2011-03-11
      • 2014-07-01
      • 1970-01-01
      • 2014-11-13
      • 2017-02-07
      • 1970-01-01
      • 1970-01-01
      • 2011-10-20
      • 1970-01-01
      相关资源
      最近更新 更多