I have a class Category, that represents products category... So I created a View that shows a Treeview with my Categories on left ... When user select a TreeView Node, I´d like to show all the Category data in the same Page/View (On right)
What I did so far is load the JQuery TreeView via Ajax... And added a click event on each TreeView Node... The click calls, via Ajax, the selected Category, like that (CategoryController):
[HttpGet]
public ActionResult GetCategory(string idCategory)
{
if (ModelState.IsValid)
{
var _category = _categoryRepository.Get(Convert.ToInt16(idCategory));
if (Request.IsAjaxRequest())
return Json(_category, JsonRequestBehavior.AllowGet);
return RedirectToAction("Index");
}
return View();
}
So, I got the Category JSON on client, and have to manually fill all the fields ...
Is that the right/best way to do that? Am I missing something?
Thanks so far
Paul