This is a migrated thread and some comments may be shown as answers.

Not paging with json.

1 Answer 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
tomato
Top achievements
Rank 1
tomato asked on 05 Apr 2012, 09:53 AM
Hi All.
We have a source.
var dataSource =  {TotalItemCount:10,data: [{"Name" : "Avocado","Status" : "exists"},
                          {"Name" : "Apple","Status" : "exists"},
                          {"Name" : "Orange","Status" : "exists"},
                          {"Name" : "Grape","Status" : "exists"},
                          {"Name" : "Grapefruit","Status" : "exists"},
                          {"Name" : "Pear","Status" : "exists"},
                          {"Name" : "Fig","Status" : "exists"},
                          {"Name" : "Melon","Status" : "exists"},
                          {"Name" : "Longan ","Status" : "exists"},
                          {"Name" : "Starfruit","Status" : "exists"}]}
                          
<script>
                $(document).ready(function () {
                var grid_1;
                grid_1 = $('#grid_1').kendoGrid({
                    dataSource:{
                                 data: dataSource,
                                 type: 'json',   
                                 pageSize:4,
                                 serverPaging: true,
                                 serverSorting: false,
                                 schema: {
                                         data: function(result)  {      
                                            return result.data || result;
                                            } ,
                                         total: function(result) {
                                         var data = this.data(result);
                                         return result.TotalItemCount || result.length || 0;;
                                          }  
                                        }   
                               },
                    pageable: true,
                    columns: [{
                            field: 'Name',
                            title: 'Name',
                            },{
                            field: 'Status',
                            title: 'Status',
                            }]
                }).data('kendoGrid');                
            });
</script>  
 Everything works fine if set "serverPaging: false". So, if you put " serverPaging: true "grid always displays all the data on page 1. Please help me solve this problem . Thanks for any help.

1 Answer, 1 is accepted

Sort by
0
Nathan
Top achievements
Rank 1
answered on 06 Apr 2012, 07:01 PM
It is not paging properly because server paging assumes that you are getting data from a server that will perform the paging operation and return the appropriate subset of JSON data.  You can read more about the behavior in the documentation for the datasource widget here.
Tags
Grid
Asked by
tomato
Top achievements
Rank 1
Answers by
Nathan
Top achievements
Rank 1
Share this question
or