Lets say, I have a model like the following:
public class AssignmentListViewModel
{
public string JsonAssignmentList { get; set; }
}
Loading the model:
model.JsonAssignmentList = Newtonsoft.Json.JsonConvert.SerializeObject(assignmentList.Assignments);
On the client when I create new kendo.data.TreeListDataSource, I try to do the following and get error
"SCRIPT1028: Expected identifier, string or number"
var json = JSON.parse(@Model.JsonAssignmentList);
var dataSource = new kendo.data.TreeListDataSource({
@*data: JSON.stringify(@Model.JsonAssignmentList),*@
data: json,
// Enable batch updates
batch: true,
// Define the model schema
schema: {
model: {
id: "Id",
fields: {
Id: { type: "number", editable: false, nullable: false },
parentId: { from: "ChildAssignmentListId", type: "number", defaultValue: 0 },
Step: { validation: { required: true } },
AssigneeDisplayName: { validation: { required: true } },
Description: { validation: { required: true } },
Status: { validation: { required: true } },
StatusText: { validation: { required: true } },
Instructions: { validation: { required: false } },
//Deadline: { validation: { required: false } },
DeadlineDueDateText: { validation: { required: false } }
}
}
}
});
How can I return json string from the controller and bind it to a kendo treelist?