“没有要显示的记录"在Telerik的TreeList中 [英] "No records to display" in Telerik's TreeList

查看:129
本文介绍了“没有要显示的记录"在Telerik的TreeList中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的TreeList,我想用一些值填充它. 我的树列表:

I have simple TreeList, which I want to be filled up with some values. My TreeList:

@(Html.Kendo().TreeList<Book>()
            .Name("BooksTreeList")
            .Columns(columns =>
            {
                columns.Add().Field(c => c.BookName);
                columns.Add().Field(c => c.BookAuthor);
            })
            .Filterable()
            .Sortable()
            .DataSource(dataSource => dataSource
                .Read(read => read.Action("ReadAllBooks", "Catalog"))
                .ServerOperation(false)
                .Model(m =>
                {
                    m.Id(c => c.BookId);
                    m.ParentId(c => c.ParentId);
                    m.Expanded(true);
                    m.Field(x => x.BookId);
                    m.Field(x => x.BookAuthor);
                })
            ))

还有我的控制器类:

public async Task<IActionResult> ReadAllBooks([DataSourceRequest] DataSourceRequest request)
{
    var result = (await GetAllBooks())
      .ToTreeDataSourceResult(
      request,
      x => x.BookId,
      x => x.ParentId);
    return Json(result);
}
private async Task<List<BookViewModel>> GetAllBooks()
{
   return await _dbContext.Books.Select(x => new BookViewModel()
   {
      BookId = x.CodingId,
      BookName = x.BookName,
      BookAuthor = x.BookAuthor,
      ParentId = x.ParentId
   }).ToListAsync();
}

但是,当我进入页面时,即使有记录,我的树形列表也始终显示没有要显示的记录",我在调试器的帮助下对其进行了检查. 我应该如何正确填写我的TreeList?

But when I'm entering the page, my treelist always shows "No records to display" even if I have records, I checked it with the help of the debugger. How should I fill my TreeList correctly?

推荐答案

我有相同的错误,然后我对根元素使用Guid.Empty. 根元素的ParentId应该为NULL .尝试使用Guid吗?而不是guid,并为其分配NULL.

I have same error then I use Guid.Empty for Root elements. Root elements should have ParentId is NULL. Try to use Guid? instead of guid, and assign to it NULL.

链接: http://www.telerik.com/forums/no-records-to-display-959da9677068

这篇关于“没有要显示的记录"在Telerik的TreeList中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆