I am not sure how to approach this particular case. I have a json dataset coming back from a web service and it returns the following data:
In order to make the grid editable, I have to supply a model and an ID, but not sure how to specify this when the data source has the ID in an child attribute element.
Here is the code:
"WFP_MacroDemandForecastResponse": {
"Results": {
"@ViewName": "WFP_MacroDemandForecast",
"RowSet": {
"@ColDims": "Workforce Planning Value",
"Rows": [
{
"WorkforcePlanningMeasure": {
"@Name": "HC Demand",
"@DimName": "Workforce Planning Measure",
"@ID": "Headcount Demand",
"#text": "HC Demand"
},
"Value": "0",
"ChangeRate": "0",
"BaseYear": "0",
"ForecastDriver": "0",
"_5YearGoal": "0",
"Year1": "0",
"Year2": "0",
"Year3": "0",
"Year4": "0",
"Year5": "0"
},
{...rows node repeats...}
In order to make the grid editable, I have to supply a model and an ID, but not sure how to specify this when the data source has the ID in an child attribute element.
Here is the code:
this.Data = new kendo.data.DataSource({
transport: {
read: {
dataType: "json"
}
},
batch: true,
schema: {
data: "WFP_MacroDemandForecastResponse.Results.RowSet.Rows",
model: {
id: "WorkforcePlanningMeasure",
fields: {
WorkforcePlanningMeasure: { editable: false }, // ???????
ChangeRate: { editable: true },
BaseYear: { editable: true },
_5YearGoal: { editable: true },
Year1: { editable: true },
Year2: { editable: true },
Year3: { editable: true },
Year4: { editable: true },
Year5: { editable: true }
}
}
}
});
$('#wfp_DemandMacroProjection').kendoGrid({
dataSource: this.Data,
sortable: true,
pageable: true,
rowTemplate: kendo.template($("#row-template").html()),
columns: [
{ field: "WorkforcePlanningMeasure[\"@Name\"]", title: "Metric", width: 200 },
{ field: "ChangeRate", title: "Change Rate", width: 30 },
{ field: "BaseYear", title: "Base Year", width: 30 },
{ field: "_5YearGoal", title: "Goal", width: 30 },
{ field: "Year1", title: "Year 1", width: 30 },
{ field: "Year2", title: "Year 2", width: 30 },
{ field: "Year3", title: "Year 3", width: 30 },
{ field: "Year4", title: "Year 4", width: 30 },
{ field: "Year5", title: "Year 5", width: 30 }
],
editable: true
});