How to split the DataSource JSON response

2 posts, 1 answers
  1. Gary
    Gary avatar
    62 posts
    Member since:
    Sep 2013

    Posted 14 Feb 2012 Link to this post

    I am presently returning dataType 'json' in a kendo DataSource that is assigned to a grid.

    I would also like to display the total number of rows returned. Therefore, I modified my JSON result to include this information in the result, and I have assigned the data being returned to a rows property:

        { count: 99, rows: { ... } }

    I need help with two things:

    1. How do I associate the kendo Grid dataSource to the rows property of the JSON result?
    2. How can I retrieve the count property from the dataSource result?

    Thanks,
    Gary
  2. Answer
    William
    William avatar
    23 posts
    Member since:
    Jan 2012

    Posted 14 Feb 2012 Link to this post

    Here is how I do both items.  First, I use the schema configuration object and set the result count, through "total."  Next, I use the dataSource configuration and set it to the variable I created called "dataSource" (yes, very original).  Hope this helps. 

    Wade

    var dataSource = new kendo.data.DataSource({  
        transport: {
         read: {
          url: "/app/handlers/blah.ashx",
          dataType: "json",
          data: {}
         }
        },
        schema: {
         data:"results",
         total:"totalCount"
        },
        pageSize:100,
        serverPaging:true,
        serverSorting:true
       });
     
       $("#grid").kendoGrid({
        dataSource:dataSource,
        columns: [
         ...columns...
        ],
        pageable:true,
        scrollable:true,
        sortable:true,
        groupable:true,
        height:500
       });
  3. Kendo UI is VS 2017 Ready
Back to Top