【发布时间】:2015-05-15 15:15:17
【问题描述】:
我们有 Kendo 调度程序,我们在其中声明类别。在事件模型中,我们有categories 字段,它代表字符串数组。
在调度器声明中我们也有资源,例如:
resources: [{
field: "categories",
dataSource: [{
text: "",
value: "red",
color: "#FF0000"
}, {
text: "",
value: "green",
color: "#00FF00"
}, {
text: "blue",
value: "blue",
color: "#0000FF"
}],
multiple: true,
title: "Category"
}],
在调度器编辑模板中我们有
<label for="categories">Categories</label>
<select data-bind="value:categories" name="categories" id="categories" multiple="multiple" data-placeholder="Select categories...">
</select>
在调度器中edit(e)回调
var categ_editor = $("#categories").kendoMultiSelect({
dataTextField: "value",
dataValueField: "value",
itemTemplate: '<div class="k-state-default" style=\"width:100%; height:16px;\" ><div style=\"background-color:#:data.color#; width:14px; height:14px;display:inline-block;\" ></div> #: data.value #</div>',
tagTemplate: '<span class="k-state-default"><b style=\"background-color:#:data.color#;\" > </b> #: data.value #</span>',
dataSource: {
data: [{
text: "",
value: "red",
color: "#FF0000"
}, {
text: "",
value: "green",
color: "#00FF00"
}, {
text: "",
value: "blue",
color: "#0000FF"
}]
}
}).data("kendoMultiSelect");
因此,调度程序显示一切正常,并且正确处理多个值。
但是当我编辑类别时,调度程序会像这样发送整个Category 对象(带有text 和color)
"Categories": [{
"text": "",
"value": "red",
"color": "#FF0000"
}, {
"text": "",
"value": "green",
"color": "#00FF00"
}]
但正确的 JSON 必须是 "Categories":["red","green"]"
如何解决此问题?
【问题讨论】:
-
SO有代码格式吗?
标签: json kendo-ui telerik kendo-scheduler kendo-multiselect