我試圖通過Telerik使用KendoUI,並從通用處理程序中獲取一個treeview以綁定到動態JSON。KendoUI TreeView Dynamic JSON
在我的通用處理程序中,我使用Newtonsoft.Json將List轉換爲我的JSON結果,該結果非常好,甚至可以與不同的KendoUI控件(圖表)一起使用。
這裏是我儘可能的JavaScript構建樹狀:
var treeSource = new kendo.data.DataSource({
transport: {
read: {
url: "Services/CategoryHandler.ashx",
dataType: "json",
contentType: "application/json; charset=utf-8",
type: "GET"
}
}
});
$("#treeview").kendoTreeView({
dataSource: treeSource
});
這裏是返回的JSON的縮短的例子:
[
{
"text":"Node 1",
"expanded":true,
"items":null
},
{
"text":"Node 2",
"expanded":true,
"items":null
}
]
「項目」將分集在樹上。
當我直接添加項目到數據源,如:
var treeview = $("#treeview").kendoTreeView({
dataSource: [
{ text: "Item 1", expanded: true, items: [
{ text: "Item 1.1" },
{ text: "Item 1.2" },
{ text: "Item 1.3" }
] },
{ text: "Item 2", items: [
{ text: "Item 2.1" },
{ text: "Item 2.2" },
{ text: "Item 2.3" }
] },
{ text: "Item 3" }
]
})
它工作得很好。當我調用寫出JSON的服務時,它不工作,我的意思是不起作用,沒有數據顯示,它是空白的。
對於我可能缺少的任何想法或者我如何驗證數據的指導,甚至是從服務中返回,甚至正確填充我的DataSource?
感謝
好感謝。我找到了一個解決方法,我做了一個$ .ajax GET,並使用字符串結果綁定到樹視圖。我期待KendoUI更新:)再次感謝。 – CodeLikeBeaker 2012-01-04 22:56:02
KendoUI網格是否綁定到HttpHandler? – 2012-02-07 22:55:35