Forum
12:16
05/08/2008
Hi,
I have a problme with the treegrid that really baffles me.
Some context:
I have a grid with a custom formatter, and a switch to change this grid to a treegrid (with a .GridUnload method)
this is some code:
colModel:[ ....
{name:'info',index:'info', width:40,formatter:abk_testFormat,resizable:false,search:false,sortable:false,jsonmap:"name"}
],
and my abk_testFormat:
abk_testFormat = function(el, cellval, opts){//used to display the 'info' link
console.log("test1",opts);
console.log("test2",opts.rowData.id);
console.log("test3",opts.rowData.level);
...other stuff
What I try is to get the "level" from the row in the grid.
In the above example test1 and test2 give me correct results, but test3 always returns undefined. when i click in firebug on the result of test1, i get a DOM view, and there i can see the level element. But it doesn't work in the js.
Any idea?
Or another way to look at this problem? (basicly: i need to display a link to an info page only for the children, not for the root elements)
Thanks in advance,
Stefan
09:42
Moderators
30/10/2007
Hello Stefan,
Nothing wrong here.
The limitation is that the level field is not accesable during this operations. To explain better. Level field is the last field (if I remember right) and is provided as last in the data.
Example if you have field1, field2, field3,..
then if you format the data of field2 you have acces to field1 and field2, but not to field3, since this field is not yet fetched from the grid.
To resolve the problem
1. You can use afterInsertRow event to add a link, where all the row info is available
2. We can use some tricky way to do this, but my question is in wich format is your data - xml or json? The idea is to use named conventions in the data, wehre you provide the level element before the info element.
Hope this helps
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
05:39
05/08/2008
ah, I see.
I'm using JSON, and my data is like this:
{"total":"1","rows":[{"level":"0","isLeaf":"false","expanded":"false","description":" group description" ,"name":"groupname01","parent":"null","id":"groupname01"},{"level":"1","isLeaf":"true","expanded":"true" ,"name":"name02","parent":"groupname01","id":"name02"} ....
So the level is sent first.
I don't have "info" in my JSON, this is an extra column in the view, that I map to the name (with jsonmap:"name") because i need that to construct the url.
So I think i have everything for option 2, or do i need to do something else? I'm not sure I understand "named conventions", do you mean i need to explicitly define in my jsonReader to use "level"?
Thanks already,
Stefan
15:26
Moderators
30/10/2007
Hello Stefan,
This is what I mean.
"I'm not sure I understand “named conventions”, "
sorry I mean data is provided as name:value i.e. the way that you do.
Please let me known if the option 2 work.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
11:52
05/08/2008
sorry i took some time to answer, i had to deliver the application.
In the end we decided to remove the treegrid from this applicatoin, due to performance issues: i have a tree with 2 root elements and each one has about 400-500 children. it loads quickly, but closing the folder (to hide the children) it took about 8 sec's!
Anyhow, back to the original problem:
I've tried it like this:
colNames:['level','Id','Name','Description','info'],
colModel:[
{name:'level',index:'level', width:40,jsonmap:"level"},
{name:'id',index:'id', width:40, hidden:true},
{name:'name',index:'name', width:150},
{name:'description',index:'description', width:150},
{name:'info',index:'info', width:40,formatter:abk_testFormat,resizable:false,search:false,sortable:false,jsonmap:"name"}
],
And this in my formatter:
abk_testFormat = function(el, cellval, opts){//used to display the 'info' link
console.log("opts3:",opts.rowData);
console.log("opts4:",opts.rowData.level);
Still, opts4 always return "undefined".
I didn't want to go for the first solution (use "afterInsertRow") because of the amount of rows I could have. But I'll try that, and let you know if it works.
Stefan
Most Users Ever Online: 715
Currently Online:
34 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