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

ListView + Pager

1 Answer 447 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Ashleigh L
Top achievements
Rank 1
Ashleigh L asked on 05 Jan 2016, 06:53 PM

How does the paging work in the ListView selection example (http://demos.telerik.com/kendo-ui/listview/selection)? I've checked the data and there doesn't appear to be any information in the JSON about total rows/item count.

I've copied the example into my own project, and changed the datasource to pull from our DB, and the pager is showing 0 rows/no items to display. This is the JSON I'm passing to the list view/pager:

{"Icons":[{"Name":"fa-icon-bolt","ID":23},{"Name":"fa-icon-book","ID":3},{"Name":"fa-icon-building","ID"
:32},{"Name":"fa-icon-building-o","ID":24},{"Name":"fa-icon-calculator","ID":15},{"Name":"fa-icon-car"
,"ID":18},{"Name":"fa-icon-certificate","ID":2},{"Name":"fa-icon-cloud","ID":6},{"Name":"fa-icon-cog"
,"ID":33},{"Name":"fa-icon-desktop","ID":4},{"Name":"fa-icon-diamond","ID":26},{"Name":"fa-icon-exclamation"
,"ID":29},{"Name":"fa-icon-file","ID":25},{"Name":"fa-icon-fire-extinguisher","ID":36},{"Name":"fa-icon-flask"
,"ID":16},{"Name":"fa-icon-globe","ID":11},{"Name":"fa-icon-graduation-cap","ID":1},{"Name":"fa-icon-h-square"
,"ID":20},{"Name":"fa-icon-headphones","ID":12},{"Name":"fa-icon-info","ID":27},{"Name":"fa-icon-laptop"
,"ID":8},{"Name":"fa-icon-line-chart","ID":19},{"Name":"fa-icon-mobile","ID":9},{"Name":"fa-icon-newspaper-o"
,"ID":10},{"Name":"fa-icon-plus","ID":28},{"Name":"fa-icon-puzzle-piece","ID":13},{"Name":"fa-icon-road"
,"ID":34},{"Name":"fa-icon-rocket","ID":35},{"Name":"fa-icon-share-square-o","ID":5},{"Name":"fa-icon-suitcase"
,"ID":30},{"Name":"fa-icon-truck","ID":14},{"Name":"fa-icon-university","ID":7},{"Name":"fa-icon-user"
,"ID":22},{"Name":"fa-icon-user-secret","ID":17},{"Name":"fa-icon-users","ID":21}]}

And the list view/pager init:

var datasource = new kendo.data.DataSource({
    transport: {
        read: {
            type: "GET",
            url: "MainController.cfc?method=getIcons",
            processData: true,
            dataType: "json",
            cache: false
        }
    },
    schema : {
        type: "json",
        data: "Icons"
    }
});
             
$("#icons_pager").kendoPager({
        dataSource: datasource
});
          
$("#icons_list").kendoListView({
    dataSource: datasource,
    selectable: "multiple",
    template: kendo.template($("#icon_list_template").html())
});

1 Answer, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 08 Jan 2016, 10:00 AM
Hi Shimmoril,

When the data response is an array, its length is calculated and used as the total value. When the response is an object, you'll need to set the total explicitly in your schema. Here is the relevant section of our documentation:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.total

Check out this dojo for sample implementations, using both an array and an object for data:

http://dojo.telerik.com/Uriro

I hope this helps.

Regards,
Dimiter Topalov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ListView
Asked by
Ashleigh L
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or