Kendo Mvc Treelist shows "No records available." after upgrading

328 Views Asked by At

I am using Kendo for Asp.Net MVC in my application. Recently I upgraded to version 2021.2.616 After that the treelist stopped showing data. Only "No records available." is shown no data in treelist

The ajax is returning data correctly.

There are no console errors or any other errors shown.

Some additional info:

This is the code that returns the data from action

IEnumerable<CategoryModel> result = ... linq query here ...;
return Json(result.ToTreeDataSourceResult(request,
                    e => e.Id,
                    e => e.ParentCategoryId,               
                    e => e                   
                    ));
2

There are 2 best solutions below

0
maX On

The problem was with value of parent category - ie ParentCategoryId.

When using 2021.2.616 : For root - ie if there is no parent - the value should be 0 (zero). Null wont work.

The confusion was because in the previous Kendo version that we had (2019.x.xxx), this was not the case. It could either be null or zero. In my case the value was null.

So, I hope this answer helps those who are upgrading to newer versions of kendo.

0
Rushik On

I have facing the same issue using Kendo Treelist latest version (2023.x.xxx).

I have found a solution for displaying "Kendo Mvc Treelist shows "No records available.".

The root cause for this issue: If there is no children record then return has children variable 0 or 1, but it's not working. Only check and add a condition for when 0 value then set false and when 1 value then set true, that's it no more changes are required in your code.

Controller get list record code screen shot attached.