happyZZR1400
happyZZR1400

Reputation: 2405

Something wrong with knockout-kendo pager of gird

I'm working with grid, everything is perfect: i can update delete and add rows, and changes are being updated immediatly but i have a problem with the pager: even in example page http://rniemeyer.github.com/knockout-kendo/web/Grid.html

,when records in grid are fewer than one pageSize : the message is on pager is:"NaN - NaN of 3 items" (which is wrong, it must be like "1 - 1 of 3 items") Is where any workaround to solve this little problem?

Thanks Forward

Upvotes: 1

Views: 1666

Answers (3)

Vicky
Vicky

Reputation: 829

<div id="grid" class="grid" data-bind="kendoGrid: {
data: Reminderlist, scrollable: false, resizable: true, selectable: false, scrollable: false, sortable: true, selectable: 'multiple cell', pageable: true, groupable: true, dataSource: { pageSize: 20 },
                           columns: [{ field: 'Duration', title: 'Duration' },
                                     { field: 'Subject', title: 'Subject' },
                                     { field: 'EmailMessage', title: 'Email Message' },
                                     { field: 'SMSText', title: 'Message Text' }
                                    ], change: GridChange
}">
</div>

dataSource: { pageSize: 20 } specify like this....

if u mention only pageSize: 20 like this ,it doesn't works in sometiomes

Upvotes: 1

happyZZR1400
happyZZR1400

Reputation: 2405

Firstly, thank you very much OnaBai, you helped me very much. Meanwhile i found another trick, for writing the same thing in knockoutjs customHandler way :

 <div id="parcels_Grid" data-bind="kendoGrid:{ dataSource:
 {data:someData
 ,pageSize:3} 
 ,data:someData, rowTemplate: 'rowParcelTmpl', altRowTemplate:   
 'altParcelTmpl',   useKOTemplates: true }"> </div>

Notice, that you must specify either the "dataSource" and "data" attributes (otherwise it should not work)

Upvotes: 1

OnaBai
OnaBai

Reputation: 40917

The problem is because pageSize is not defined. For demonstrating it, define a grid with id set to grid. Then add the following HTML tag:

<a id="fix" href="#" class="k-button">Fix</a>

and the following JavaScript code:

$("#fix").on("click", function () {
    var grid = $("#grid").data("kendoGrid");
    grid.dataSource.pageSize(2);
});

You will see that initially it shows the NaN - NaN of 3 items but as soon as you click on Fix button it will show 1 - 2 of 3 items.

Upvotes: 6

Related Questions