Kendo网格中包含变量中的XML数据 [英] Kendo grid with XML data in a variable
本文介绍了Kendo网格中包含变量中的XML数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I'm trying to set dataSource to a variable containing xml information but the Kendo Grid show with any data.
My variable returnValue value is;
"<?xml version="1.0" encoding="UTF-8"?>
<logData>
<log><historyId>12</historyId><userId>1</userId><taskDate>2013-08-12 00:00:00</taskDate></log>
<log><historyId>13</historyId><userId>1</userId><taskDate>2013-08-14 00:00:00</taskDate></log>
<log><historyId>14</historyId><userId>1</userId><taskDate>2013-08-15 00:00:00</taskDate></log>
<log><historyId>15</historyId><userId>1</userId><taskDate>2013-08-19 00:00:00</taskDate></log>
<log><historyId>16</historyId><userId>1</userId><taskDate>2013-08-21 00:00:00</taskDate></log>
</logData>"
My html code is;
$("#grid").kendoGrid({
dataSource: {
data: returnValue,
schema: {
model: {
fields: {
historyId: { type: "number" },
userId: { type: "number" },
taskDate: { type: "string" }
}
}
},
pageSize: 20
},
height: 550,
scrollable: true,
sortable: true,
filterable: true,
pageable: {
input: true,
numeric: false
},
columns: [
{ field: "historyId", title: "History ID", format: "{0:c}", width: "130px" },
{ field: "userId", title: "User ID", format: "{0:c}", width: "130px" },
{ field: "taskDate", title: "Task Date", width: "130px" }
]
});
推荐答案
(# grid)。kendoGrid({
dataSource:{
data:returnValue,
schema:{
model:{
fields:{
historyId:{输入:number},
userId:{type:number},
taskDate:{type:string}
}
}
},
pageSize:20
},
身高:550,
可滚动:true,
sortable:true,
filterable: true,
pageable:{
input:true,
numeric:false
},
columns:[
{field:historyId,title: 历史记录ID,格式:{0:c},宽度:130px},
{字段:userId,标题:用户ID,格式:{0:c},宽度:130px},
{字段:taskDate,标题:任务日期,宽度:130px}
]
});
("#grid").kendoGrid({ dataSource: { data: returnValue, schema: { model: { fields: { historyId: { type: "number" }, userId: { type: "number" }, taskDate: { type: "string" } } } }, pageSize: 20 }, height: 550, scrollable: true, sortable: true, filterable: true, pageable: { input: true, numeric: false }, columns: [ { field: "historyId", title: "History ID", format: "{0:c}", width: "130px" }, { field: "userId", title: "User ID", format: "{0:c}", width: "130px" }, { field: "taskDate", title: "Task Date", width: "130px" } ] });
根据Telerik的说法,你必须定义xml的类型和根...
According to Telerik, you have to define the type and root of xml...
schema: {
type: 'xml',
data: '/logData/log',
model: {
fields: {
historyId: 'historyId/text()',
userId: 'userId/text()',
taskDate: 'taskDate/text()
}
}
},
还删除<?xml version =1.0encoding =UTF-8?>部分来自字符串......
Remove also the <?xml version="1.0" encoding="UTF-8"?> part from the string...
这篇关于Kendo网格中包含变量中的XML数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文