Forum
Hi,
I am using the tree facility + adjacency model + json + ASP.NET MVC more or less successfully but the nodes are all expanded after the grid is loaded. The nodes also only collaps after the second click. How can I prevent this? Thanks in advance. It follows some code:
$("#items").jqGrid({
height: 'auto',
url: "<%= Url.Content("~/EIDItems/getItems") %>",
datatype: 'json',
mtype: 'GET',
width: 500,
colNames: ['ItemId','ItemName'],
colModel: [
{ name: 'ItemId', index: 'ItemId', editable: false, resizable: true, sorttype: "int", width: 75, search: false },
{ name: 'ItemName', index: 'ItemName', editable: false, resizable: true, sorttype: "text", width: 75, search: true }
],
pager: $('#item_pager'),
rowList: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
rowNum: 10,
userdata: 'userdata',
sortname: 'ItemId',
sortorder: 'desc',
viewrecords: true,
imgpath: "<%= Url.Content("~/Content/jqGridthemes/steel/images") %>",
caption: 'Items',
multiselect: false,
toolbar: [true, "top"],
treeGridModel: 'adjacency',
ExpandColumn : 'ItemName',
treeGrid: true,
treeReader : { level_field: "level_field",parent_id_field: "parent_id_field", leaf_field: "leaf_field", expanded_field: "expanded_field" },
loadError:
function(xhr, st, err) {
showErrorMessage("Type: " + st + "; Response: " + xhr.status + " " + xhr.statusText);
},
loadComplete:
function() {
if($("#items").getUserData().TYPE == 'Error')
{
showErrorMessage($("#items").getUserData().MSG );
}
},
}).navGrid('#item_pager', { edit: false, add: false, del: false, search: true, refresh: true, refreshtext: "Refresh", searchtext: "Filter"}
)
The JSON of my test data looks like this:
{"total":7,"page":"1","records":"13 [13]","userdata":{"TYPE":"","MSG":""},"rows":[{"id":"5","cell":["5"
,"parent1",0,null,"false","false"]},{"id":"6","cell":["6","c2",1,5,"false","false"]},{"id":"7","cell"
:["7","c3",2,6,"true","false"]},{"id":"8","cell":["8","c1",1,5,"true","false"]},{"id":"9","cell":["9"
,"parent2",0,null,"false","false"]},{"id":"10","cell":["10","c5",1,9,"false","false"]},{"id":"11","cell"
:["11","c6",2,10,"true","false"]},{"id":"12","cell":["12","c4",1,9,"true","false"]},{"id":"13","cell"
:["13","p",0,null,"false","false"]},{"id":"14","cell":["14","b",1,13,"false","false"]},{"id":"15","cell"
:["15","c",2,14,"false","false"]},{"id":"16","cell":["16","d",3,15,"true","false"]},{"id":"17","cell"
:["17","a",1,13,"true","false"]}]}
Most Users Ever Online: 715
Currently Online:
45 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66