剣道ツリーのメニューを作ろうとしています。データをウィジェットにフィードする必要がある形式がわかりません。私はこれまでにこれを試しました:
モデル:
public class TreeModel
{
public int ID { get; set; }
public string Name { get; set; }
public string URL { get; set; }
public int? ParentsID { get; set; }
public bool HasChild { get; set; }
}
コントローラ:
public ActionResult LoadMenu()
{
List<TreeModel> list = new List<TreeModel> {
new TreeModel() { ID=1, Name="Setup", URL="m.facebook.com", HasChild=true},
new TreeModel() { ID=10, Name="Leave", URL="google.com", ParentsID=1, HasChild=false},
new TreeModel() { ID=2, Name="EmployeeInfo", URL="m.facebook.com", HasChild=true},
new TreeModel() { ID=11, Name="Basic Employee", URL="m.facebook.com", HasChild=false, ParentsID=2},
};
var nodes = (from n in list
where n.HasChild == true
select n).ToList();
return Json(nodes, JsonRequestBehavior.AllowGet);
}
私の見解でのスクリプト:
<script type="text/javascript">
homogeneous = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: "/Home/LoadMenu",
//dataType: "json",
type: "GET"
}
},
schema: {
model: {
id: "ID",
hasChildren: "HasChild"
}
}
});
$(document).ready(function () {
$("#treeMenu").kendoTreeView({
dataSource: homogeneous,
dataTextField: "Name",
dataUrlField: "URL",
hasChildren:"ParentsID"
});
});
</script>
現在の出力と問題は、スクリーン ショットにマークされています。
助けてください。ありがとう。