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

How to split the DataSource JSON response

1 Answer 268 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Gary
Top achievements
Rank 1
Gary asked on 15 Feb 2012, 01:56 AM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
William
Top achievements
Rank 1
answered on 15 Feb 2012, 03:21 AM
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
   });
Tags
Data Source
Asked by
Gary
Top achievements
Rank 1
Answers by
William
Top achievements
Rank 1
Share this question
or