Arslan Ali
Arslan Ali

Reputation: 231

Dojox datagrid with QueryReadStore virtual pagining issue

I am using dojox.grid.DataGrid along with dojox.data.QueryReadStore. I have the following code on client side:

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
        },

On the server side: $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();

But as I scroll virtual paging, does not work. It only makes the first request with start=0&count=25 and does not make further requests.

Please help.

Upvotes: 0

Views: 510

Answers (1)

Ravi Khakhkhar
Ravi Khakhkhar

Reputation: 1964

As far as I know, for QueryReadStore you need to have a response like,

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

So, no need to set no of items in response headers. Your JSON response should be in above format.

Upvotes: 2

Related Questions