Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
newbie treegrid questions...
01/04/2013
22:56
Avatar
bergzilla
Ames, Iowa
Member
Members
Forum Posts: 4
Member Since:
22/02/2013
sp_UserOfflineSmall Offline

 Say I have a simple hierarchy of XML like…

<root>

            <item label="Parent1″ level="0″ leaf="false" parent="" id="Parent1″>

                      <item label="Child1″ level="1″ leaf="true" parent="Parent1″ id="Parent1/Child1″>

                      <item label="Child2″ level="1″ leaf="true" parent="Parent1″ id="Parent1/Child2″>

            </item>

            <item label="Parent2″ level="0″ leaf="false" parent="" id="Parent2″>

                     <item label="Child1″ level="1″ leaf="true" parent="Parent2″ id="Parent2/Child1″>

            </item>

</root>

And my treegrid is setup something like this…

var colNames = ['Label'];
var colModel = [ {name:'label', xmlmap: function (obj) { return $(obj).attr("label");}} ];

$("#myTreeGrid").jqGrid({

treeGrid: true,
treeGridModel: 'adjancency',
ExpandColClick: true,
ExpandColumn: 'Label',
datatype: 'xmlstring',
datastr: myXML,
colNames: colNames,
colModel: colModel,
xmlReader: {
                      root: "root", 
                      row: "item", 
                      repeatitems: false
},
treeReader: {
                      level_field: "[level]",
                      parent_id_field: "[parent]",
                      leaf_field: "[leaf]",
                      expanded_field: "[expanded]"
},
gridview: false,
caption: 'My Tree Sample',

});

Now this XML is a bit different than the single example that google is giving me. I was hoping this would work due to the little xmlmap trick being able to pull out attributes via the function call ie xmlmap: function (obj) { return $(obj).attr("label");} that I'm using in the colModel and being able to use attributes in the treeReader and that all seems to work well but the one thing that I can't get to work for the life of me is being able to expand/collapse the parent.

I'm getting what looks like parent and children in the tree(they've got the right icons) but they don't seem to be connected. Children are starting off fully expanded even though their expand field is set to false and clicking on the parent's expand/collapse triangle just seems to stick to expand regardless of what the field was set to.

I'm guessing I'm missing a field in my treeReader for id to connect parent and children but all I can find in the documentation available is level_field, parent_id_field, leaf_field, and expanded_field for the adjancency model. I've also tried setting the id field in the xmlReader but haven't had any luck.

Could it also be that I'm missing a field for setting the loaded boolean? I know in the standard XML treegrid example, it's recommended that the last tag for each row be set to true(I think) to keep treegrid from contacting the server for the children's contents. Could it be that my parent expand is stuck because its trying to pull more data from the server even though I don't want it to?

Does anyone have any suggestions? I feel like I'm so close to getting this to work and I'm getting tripped up on something I'm just not finding.

Also, the links that I'm guessing explain what the nested and adjancency models really mean seem to be broken. Does anyone have a simple explanation for the difference between the two? Judging from the differences in their treeReaders, they seem a bit backwards to me. Wouldn't adjacent mean things are side by side which would use the left/right fields?

And kind of a side comment that I hope doesn't come off as snarky :) It's kind of a bummer to me that I've got a very hierarchical XML but I still have to go thru and explicitly setup parent/child relationships via either tags or attributes.

Thanks for any advice you can drop on me!

02/04/2013
00:28
Avatar
bergzilla
Ames, Iowa
Member
Members
Forum Posts: 4
Member Since:
22/02/2013
sp_UserOfflineSmall Offline

Ugh, my name is berg and I am lord of the idiots...

Adjacency only has one n...

After correcting that, it all works great! Thanks anyone and everyone who took a look!

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
76 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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information