如何为剑道图表和剑道多重选择使用相同的数据源? [英] how can I use same data source for Kendo chart and kendo multi select?
问题描述
我正在使用剑道角度图和多选.现在,我被两次调用相同的api来加载两者中的数据.有没有办法在同一个api调用中定义多个架构?我的数据就像下面的
I am using kendo angular chart and multiselect. Right now I am call same api twice to load the data in both. Is there any way to define multiple schema in same api call? My data is like following
{
"List": [
{
"Name": "xyz",
"Activation": "2016-12-08",
"End": "2016-12-09",
"Run": "45",
"Status": "FAILURE",
"color": "red"
},
{
"Name": "wqe",
"Activation": "2016-12-07",
"End": "2016-12-08",
"Run": "46",
"Status": "FAILURE",
"color": "red"
}
],
"NameList": [
{
"Name": "joo"
},
{
"Name": "foo"
},
{
"Name": "too"
}
]
}
我想在一个api调用中在网格中添加列表",并在多选中添加"NameList".
I want to add "List" in grid and "NameList" to be added in multi select in one api call.
当前,我正在使用以下代码调用api
currently I am using following code to call api
function getDataSource(requestUrl) {
var dataSource = {
transport: {
read: requestUrl,
dataType: "json"
},
schema: {
data: "List",
total: function (response) {
return response.StatisticList.length;
},
model: {
fields: {
Name: { type: "string" },
Activation: { type: "date" },
End: { type: "date" },
Run: { type: "number" },
Status: { type: "string" },
color: { type: "string" }
}
}
},
sort: { field: "ActivationTime", dir: "desc" },
pageSize: common.Grid.pageSize
};
return dataSource;
}
function getMultiSelectDataSource(requestUrl) {
var dataSource = {
transport: {
read: requestUrl,
dataType: "json"
},
schema: {
data: "NameList",
model: {
fields: {
Name1: { type: "string" }
}
}
}
};
return dataSource;
}
推荐答案
如果您亲自手动创建请求并使用 dataSource.data
分配图表和MultiSelect.
It is possible to achieve data binding of both widgets with one request in your scenario, if you make the request manually yourself, and use local (custom) transport or static dataSource.data
assignment in the DataSources of the Chart and MultiSelect.
这篇关于如何为剑道图表和剑道多重选择使用相同的数据源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!