Kendo ui Kendo treeview HierarchycalDataSource未显示子节点
我有一个剑道树视图,它显示了父节点,但没有看到子节点。谁能告诉我哪里出了问题。我对这个概念还不熟悉。我按照下面的链接,但它不工作。 服务:Kendo ui Kendo treeview HierarchycalDataSource未显示子节点,kendo-ui,treeview,Kendo Ui,Treeview,我有一个剑道树视图,它显示了父节点,但没有看到子节点。谁能告诉我哪里出了问题。我对这个概念还不熟悉。我按照下面的链接,但它不工作。 服务: [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string getParent() { using (var context = new Data.Entities()) { I
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string getParent()
{
using (var context = new Data.Entities())
{
IQueryable<ERPv2.Data.Links> dataQuery = from x in context.Links
where x.ParentID == 68
select x;
var newQry = dataQuery.AsEnumerable().Select(c => new
{
ID = c.ID,
Name = c.Name,
Children = HasChildren(231)
});
JavaScriptSerializer JSON = new JavaScriptSerializer();
return JSON.Serialize(newQry);
}
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public bool HasChildren(int ID)
{
using (var context = new Data.Entities())
{
IQueryable<ERPv2.Data.Links> dataQuery = from x in contextLinks
where x.ParentID == ID
select x;
return dataQuery.AsEnumerable().Any();
}
}
即使您尝试查看子节点,它也会尝试调用getLinks而不是getreports。 从我所看到的,你应该只有一种方法来获得父母和孩子。可以是每个父节点内的数组。
您可以将getlinks中的GetReports方法中的数据组合在一起并试一试。您应该尝试在这里使用硬编码的值来实现这一点,然后使用服务进行配置。
谢谢你的建议,我从一天开始就在尝试你说的话,但不知怎么的,我无法编写查询。我已经添加了LINQ查询,请检查并建议我更新代码
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string getParent()
{
using (var context = new Data.Entities())
{
IQueryable<ERPv2.Data.Links> dataQuery = from x in context.Links
where x.ParentID == 68
select x;
var newQry = dataQuery.AsEnumerable().Select(c => new
{
ID = c.ID,
Name = c.Name,
Children = HasChildren(231)
});
JavaScriptSerializer JSON = new JavaScriptSerializer();
return JSON.Serialize(newQry);
}
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public bool HasChildren(int ID)
{
using (var context = new Data.Entities())
{
IQueryable<ERPv2.Data.Links> dataQuery = from x in contextLinks
where x.ParentID == ID
select x;
return dataQuery.AsEnumerable().Any();
}
}