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

Basic Datasource Binding Question/Issue

1 Answer 4 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JAMES
Top achievements
Rank 1
JAMES asked on 28 Sep 2016, 11:54 PM

Brand new to the KendoUI grid tool. Some of the other developers on my team have this working, but they are building the datasource and grid as variables and then using jQuery to associate these values to the grid. I'm trying to learn the basics and build it in JSP from scratch. I think I've more or less duplicated their grid settings. The problem I'm having is that when setting "data : data" in the schema, the grid doesn't popup at all. If I take that line out, the grid shows up but no data gets populated in the grid. 

I was hoping someone can look over this code and tell me where I'm going wrong. At the least, what does it mean when the grid doesn't popup at all when setting "data : data"?

 

<div id="tableGrid">
<div id="grid"></div>
   <script>
var dataSource = new kendo.data.DataSource({
transport : {
read : {
type : "POST",
contentType: "application/json",
                       url: "/This URL should work because it works elsewhere"
},
parameterMap : function(options, operation) {
return JSON.stringify(options);
}
},
schema : {
data : data,
type : "json",
model : {
fields : {
Field1: { type: "number"}
}
}
},
serverFiltering : true,
serverGrouping : true,
serverSorting : true,
serverPaging : true,
pageSize : 10
});

alert(JSON.stringify(dataSource));

$("#grid").kendoGrid({
 dataSource: dataSource,
 pageable: true,
});
</script>
   
</div>

1 Answer, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 30 Sep 2016, 02:20 PM
Hi James,

The Kendo UI Data Source schema data may be necessary to retrieve the server response. It depends on the structure of the response whether this configuration will be required. We expect to see the name of the property which contains an array of the data:

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

Example configuration of the schema based on the response:
// server response:
{foo: [1,2,3]}
 
schema:{
 data: "foo"
}

Kind Regards,
Alex
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Tags
Grid
Asked by
JAMES
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or