This is a migrated thread and some comments may be shown as answers.

Kendo Treeview Not Updating Remote Data From Datasource

1 Answer 189 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Development Team
Top achievements
Rank 1
Development Team asked on 19 Aug 2013, 02:10 AM
I'm biding a treeview to a remote data and at this point the data is displayed correctly. The problem: when I change the data in the database and refresh my page, the treeview doesn't reflect the new data. It seems that the treeview is not calling the json action anymore after the first load.

I tried to work with LoadOnDemand and several other methods, but nothing worked so far. I need to refresh the data because when users drag and drop the nodes, the treeview will be updated in the database.

** Code is attached. I also just noticed that it works on Chrome but not IE 10. Thank you for any help.

I'm following this demo code: http://demos.kendoui.com/web/treeview/remote-data.html

This is my json action:

public JsonResult Categories(int? id)
{

var categories = from e in db.Categories
where (id.HasValue ? e.ParentCategoryID == id : e.ParentCategoryID == 1)
orderby(e.OrderNumber)
select new
{
id = e.CategoryID,
Name = e.CategoryNames.FirstOrDefault().Name,
ParentId = e.ParentCategoryID,
hasChildren = db.Categories.Where(j => j.ParentCategoryID == e.CategoryID).Any()
}
;

return Json(categories, JsonRequestBehavior.AllowGet);
}

This is my treeview code:

Html.Kendo().TreeView()
.Name("treeviewcategories")
.DataTextField("Name")
.DataSource(dataSource => dataSource
.Read(read => read
.Action("Categories", "Settings")
)
)
.Events(events => events
.Select("onSelect")
.DragEnd("onDragEnd")
.Expand("onExpand")
)
.DragAndDrop(true) 

1 Answer, 1 is accepted

Sort by
0
Development Team
Top achievements
Rank 1
answered on 19 Aug 2013, 06:00 PM
Resolved by changing the Kendo DataSource call to include the timespan:

<%:Html.Kendo().TreeView()
.Name("treeviewcategories")
.DataTextField("Name")
.DataSource(dataSource => dataSource
.Read(read => read
.Action("ReadCategories", "Settings", new { time = System.DateTime.Now })
)
)
.Events(events => events
.Select("onSelect")
.DragEnd("onDragEnd")
.Expand("onExpand")
)
.DragAndDrop(true) 
 

%>
Tags
TreeView
Asked by
Development Team
Top achievements
Rank 1
Answers by
Development Team
Top achievements
Rank 1
Share this question
or