Hi.
Can I use not number type for "id" field for dependencies and tasks? Or It must be number type?
For exemple guid as "dbaa0c8b-e188-4e83-8e14-b0b41dd12f0e".
And this my object for dependency:
"{
"id":"dbaa0c8b-e188-4e83-8e14-b0b41dd12f0e",
"type":1,
"predecessorId":"01415eab-f852-4cd8-af5e-4be43bba1dc2",
"successorId":"f13e95f2-402a-4819-8137-3977f31eeb5e"
}"
Thank you.
4 Answers, 1 is accepted
The gantt can work with guid. It's treated as a string and should not cause any problems. Here's a small example:
http://dojo.telerik.com/UnuDU
Regards,
Bozhidar
Telerik
Ok.
It works if GUIDs start with number but what about letter ? For example will change the '01415eab-f852-4cd8-af5e-4be43bba1dc2' to 'a1415eab-f852-4cd8-af5e-4be43bba1dc2' as result tasks does not connect.
this my example http://dojo.telerik.com/UnuDU ..
Ok.
I found a solution.
We can difine schema for tasks and for dependencies.
for dependency:
schema: {
model: {
id: "id",
fields: {
id: { from: "dependencyId", type: "string" },
type: { from: "type", type: "number"},
predecessorId: { from: "predecessorGuidId", type: "string" },
successorId: { from: "successorGuidId", type: "string" }
}
}
}
for task :
schema: {
model: {
id: "id",
fields: {
id: { from: "taskId", type: "string" },
orderId: { from: "orderId", type: "number", validation: { required: true } },
start: { from: "start", type: "date" },
end: { from: "end", type: "date" },
title: { from: "title", defaultValue: "", type: "string" }
Yes, defining the schema is the correct approach. You have to also make sure that in your service Insert method you generate and return a new Guid for the task's id. You can also define it as a default value for the field:
schema: {
model: {
id:
"id"
,
fields: {
id: { from:
"ID"
, type:
"string"
, defaultValue: kendo.guid() },
...
}
}
},
Regards,
Bozhidar
Telerik