Hello there.
I am using kendo Mvc Ui on my application.
In my scenario I have to used a tree view on the left side, and on the right the details section. when i click a node from the tree view, on details section it will show its details.
It is fine upto now, now the problem is like I need to show records from two tables on the tree.
Like, I have a sector table, Id and Name, another table category is Id, SectorId and name.
So now I have to bind the grid as
and it is based on ajax data source.
here is my configurations
My controller
This one is being used for only category navigation. I m clue less how to make it sector base from ajax datasource, I means how the tree will understand what is sector and what is category.
I am using kendo Mvc Ui on my application.
In my scenario I have to used a tree view on the left side, and on the right the details section. when i click a node from the tree view, on details section it will show its details.
It is fine upto now, now the problem is like I need to show records from two tables on the tree.
Like, I have a sector table, Id and Name, another table category is Id, SectorId and name.
So now I have to bind the grid as
Sector1
Category1
Category2
Category2-1
category2-2
Sector2
Category1
Category2
Category2-1
category2-2
here is my configurations
@(Html.Kendo().TreeView()
.Name("categoryList")
.DataTextField("Name")
.DragAndDrop(true)
.DataSource(ds =>
{
// ds.Read("ajaxCateegoryList", "category");
ds.Read(read => read.Action("ajaxCateegoryList", "category"));
})
.Events(evt =>
{
evt.Expand("expandHandler");
evt.Select("selectedHandler");
})
)
public
JsonResult ajaxCateegoryList(
string
id)
{
if
(
string
.IsNullOrEmpty(id))
id = Request.QueryString[
"id"
];
var cats =
new
List<Category>();
if
(!
string
.IsNullOrEmpty(id))
cats = _categoryService.GetAllCategoriesByParentCategoryId(Convert.ToInt64(id)).ToList();
else
cats = _categoryService.getAllParentCategories();
var model = cats.Select(x =>
{
return
new
{
id = x.Id,
Name = x.Name,
hasChildren = _categoryService.GetAllCategoriesByParentCategoryId(x.Id).Count > 0
};
});
return
Json(model, JsonRequestBehavior.AllowGet);
}