<script id="nodeTree" type="text/x-jsrender"> <input type="hidden" id="{{>Id}}_idinstalacion" value="{{>IdInstalacion}}" name="idInstalacionItem" /> {{if IsEquipo}} <div class="isequipo"></div> {{if IsParado}} <img name="wrenchImage" src="@(Url.Content("~/Content/images/icons-png/wrench-red.png"))" /> {{else}} <img name="wrenchImage" src="@(Url.Content("~/Content/images/icons-png/wrench.png"))" /> {{/if}} {{>Name}} {{else IsSubinstalacion}} <div class="isSubinstalacion"></div> {{>Name}} {{else}} {{>Name}} {{/if}} </script> @(Html.EJ().TreeView("treeInstalaciones") .TreeViewFields(d => d.Datasource(ds => ds.URL(Url.Action("GetInstalacionesTreeView", "Home"))) .Id("Id") .Text("Name") .ParentId("ParentId") .Expanded("Expanded") .HasChild("HasChild") .Query("ej.Query().addParams('idInstalacion','-1')") ) .EnablePersistence(true) .Template("#nodeTree") ) |
public JsonResult GetInstalacionesTreeView(int idInstalacion) { List<TreeEntry> arbolVM = new List<TreeEntry>(); //Padre 1 arbolVM.Add(new TreeEntry { Expanded = true, HasChild = true, Id = 1, IdInstalacion = 1, IsEquipo = false, IsParado = false, IsSubinstalacion = false, Name = "Padre" }); //Hijo activo arbolVM.Add(new TreeEntry { Expanded = true, HasChild = true, Id = 2, IdInstalacion = 1, IsEquipo = true, IsParado = false, IsSubinstalacion = false, Name = "Activo", ParentId = 1 }); //Hijo parado arbolVM.Add(new TreeEntry { Expanded = true, HasChild = true, Id = 3, IdInstalacion = 1, IsEquipo = true, IsParado = true, IsSubinstalacion = false, Name = "Activo", ParentId = 1 }); //Hijo parado arbolVM.Add(new TreeEntry { Expanded = true, HasChild = true, Id = 4, IdInstalacion = 1, IsEquipo = true, IsParado = true, IsSubinstalacion = false, Name = "Activo", ParentId = 1 }); return Json(arbolVM, JsonRequestBehavior.AllowGet); } |