Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 84751

Bind Grid to Property in DataSource

$
0
0

Hi,

We are currently evaluating the Kendo UI javascript Grid. We`d like  to bind it to a datasource populated from a remote rest service. The json returned will be similar to the json at the bottom of this post. We would like the grid to bind to the stock array but not the summary but would like the summary accessible from the datasource.

I`ve tried calling the rest service from jquery then populating the datasource using the array but this seems slower then binding the datasource to the rest service directly.

Below is an example of what we`d like to do

Many thanks

Darran

var dataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "/warehouse/report",
                    dataType: "json"
                }
            },
            schema: {
                data: "breaks",
                total: function(response) {
                    return $(response.breaks).length;
                }
            },
            groupable: true,
            sortable: true,
            pageSize: 100,
            page:1
        });
 
 
$(gridId).kendoGrid({
            dataSource: dataSource.breaks, //How do we bind to the breaks only???
            selectable: "multiple cell",
            allowCopy: true,
            columns: columnDefinitions(),
            columnMenu: true,
            filterable: true,
            sortable: {
                mode: "single",
                allowUnsort: false
            },
            pageable: {
                refresh: true,
                pageSizes: true,
                buttonCount: 5
            },
            groupable: true
        });

Example Json:

{summary{colour:red,size:10},
   stock:[{name:"name1",type:"type1"},
          {name:"name2",type:"type2"},
          {name:"name3",type:"type3"}
]}

Viewing all articles
Browse latest Browse all 84751

Trending Articles