gpt4 book ai didi

javascript - KendoUI Treeview 子项显示为未定义

转载 作者:行者123 更新时间:2023-11-30 00:12:21 24 4
gpt4 key购买 nike

我在 kendoUI 中有一个 Treeview ,其中主要节点正在调用一个 mvc Controller ,该 Controller 查看是否传入了可为 null 的 id,然后使用不同的模型。

我打的是什么网址:http://localhost:2949/Report/GetReportGroupAssignments

我看到了这个 JSON

[
{"Id":1,"ReportGroupName":"Standard Reports","ReportGroupNameResID":null,"SortOrder":1},
{"Id":2,"ReportGroupName":"Custom Reports","ReportGroupNameResID":null,"SortOrder":2},
{"Id":3,"ReportGroupName":"Retail Reports","ReportGroupNameResID":null,"SortOrder":3},
{"Id":4,"ReportGroupName":"Admin Reports","ReportGroupNameResID":null,"SortOrder":5},
{"Id":5,"ReportGroupName":"QA Reports","ReportGroupNameResID":null,"SortOrder":4}
]

现在我的 mvc Controller 看起来像这样

public JsonResult GetReportGroupAssignments(int? id)
{
var model = new List<ReportGroup>();
var defModel = new List<ReportDefinition>();

try
{
if (id == null)
{
model = _reportService.GetReportGroups("en-us").ToList();
return Json(model, JsonRequestBehavior.AllowGet);
}
else
{
defModel = _reportService.GetReportDefinitions().Where(e=>e.ReportGroupID ==Convert.ToInt32(id)).ToList();
return Json(defModel, JsonRequestBehavior.AllowGet);
}
}
catch (Exception ex)
{
Logger.Error(ex, "Error loading LoadReportList.");
return null;
}
}

我的 Kendo javascript 如下所示:

var serviceRoot = "/Report"; // "//demos.telerik.com/kendo-ui/service";
homogeneous = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: serviceRoot + "/GetReportGroupAssignments", //"/LoadReportTree", // "/Employees",
dataType: "json"
}
},
schema: {
model: {
id: "Id" //"ReportGroupName"
,hasChildren: "Id"
}
}
});

var treeview = $("#treeview").kendoTreeView({
expanded: true,
dragAndDrop: true,
dataSource: homogeneous,
dataTextField: "ReportGroupName"

}).data("kendoTreeView");

似乎调用(我发现子记录有一个在 seens 后面调用的“加载”方法,所以基本上我传入 ID 以便从其他模型(db 中的表)获取数据< br/>(Id 使用 automapper 映射到 ReportGroupID )

所以当我点击“Standard Rports”左侧时,我将所有这些子项都设置为未定义,如何让它们正确显示?

enter image description here

更新:我的 ReportDefinition 类:

public class ReportDefinition {
public override int Id { get; set; }
public string ReportKey { get; set; }
public string ReportName { get; set; }
public int? ReportNameResID { get; set; }
public string ReportDef { get; set; }
public int? ReportDefinitionResID { get; set; }
public string ReportAssembly { get; set; }
public string ReportClass { get; set; }
public int ReportGroupID { get; set; }
public int AppID { get; set; }
public int SortOrder { get; set; }
public bool IsSubReport { get; set; }
}

最佳答案

我认为您的问题是 ReportDefinition 类没有名为:ReportGroupName 的属性。这就是 TreeView 显示“未定义”的原因。

尝试将此属性添加到您的 ReportDefinition 类中,例如:

public class ReportDefinition {

// Other Properties

// I guess this property is missing
public string ReportGroupName { get; set; }

}

关于javascript - KendoUI Treeview 子项显示为未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35946776/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com