Note that there are some explanatory texts on larger screens.

plurals
  1. POJqGrid Treegrid sorting issue
    primarykey
    data
    text
    <p>I hope you can help me, I have a structure like this:</p> <pre><code>- root A -child_A1 -child_A1_1 -child_A1_2 -child_A1_3 -child_A2 -child_A2_1 -child_A2_2 -child_A2_3 - root B - child_B1 -child_B1_1 -child_B1_2 -child_B1_3 </code></pre> <p>But when I show the data in TreeGrid, it shows like this:</p> <pre><code>- root A -child_A1 -child_A2 -child_A1_1 - root B - child_B1 -child_B1_1 -child_B1_2 -child_B1_3 -child_A1_2 -child_A1_3 -child_A2_1 -child_A2_2 -child_A2_3 </code></pre> <p>Anybody knows why..??? please help, I search information about this error but don`t have luck....</p> <p>Here's my JavaScript:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function () { var lastsel; $(function () { jQuery('#tree').jqGrid({ url: '/Ubicacion/TreeGrid/', datatype: 'json', height: 250, colNames: ['Nombre', 'Descripcion'], colModel: [ { name: 'Nombre', index: 'Nombre', width: 100, sortable: true, editable: true, edittype: "text"}, { name: 'Descripcion', index: 'Descripcion', width: 80, editable: true, edittype: "text" } ], caption: 'Listado de Ubicaciones', treeGridModel: 'adjacency', sortname: 'Nombre', loadonce: true, height: 'auto', width: '500', pager: "#pager", treeGrid: true, ExpandColumn: 'Id', ExpandColClick: true, }); }); }); </code></pre> <p></p> <p>And here is the server side function that I used for generate json string:</p> <pre><code>public ActionResult TreeGrid(string sidx, string sord, int? page, int? rows) { List&lt;Ubicacion&gt; ubicacion = new List&lt;Ubicacion&gt;(); ubicacion = UbicacionRepository.GetAll().ToList&lt;Ubicacion&gt;(); int pageIndex = Convert.ToInt32(page) - 1; int totalrecords = ubicacion.Count(); JsonResult json = new JsonResult(); json.JsonRequestBehavior = JsonRequestBehavior.AllowGet; json.Data = new { sidx = "Nombre", sord = "asc", page = page, records = totalrecords, rows = (from ubi in ubicacion select new { cell = new string[] { ubi.Nombre, ubi.Descripcion, ubi.Nivel.ToString(), ubi.IdPadre == 0 ? "null" : ubi.IdPadre.ToString(), ubi.Nivel &lt; 2 ? "false" : "true", "false", "true" } }) }; return json; } </code></pre> <p>And here's the json generated:</p> <pre><code>{"total":1,"page":null,"records":18,"rows":[ {"cell":["Parent A","ubicacion","0","null","false","false","true"]}, {"cell":["Child A1","ubicacion","1","1","false","false","true"]}, {"cell":["Child A2","ubicacion","1","1","false","false","true"]}, {"cell":["Child A1_1","ubicacion","2","2","true","false","true"]}, {"cell":["Parent B","ubicacion","0","null","false","false","true"]}, {"cell":["Child B1","ubicacion","1","5","false","false","true"]}, {"cell":["Child B1_1","ubicacion","2","6","true","false","true"]}, {"cell":["Child B1_2","ubicacion","2","6","true","false","true"]}, {"cell":["Child B1_3","ubicacion","2","6","true","false","true"]}, {"cell":["Child A1_2","ubicacion","2","2","true","false","true"]}, {"cell":["Child_A1_3","ubicacion","2","2","true","false","true"]}, {"cell":["Child A2_1","ubicacion","2","3","true","false","true"]}, {"cell":["Child A2_2","ubicacion","2","3","true","false","true"]}, {"cell":["Child A2_3","ubicacion","2","3","true","false","true"]} ]} </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload