Forum
23:34
24/07/2009
hi guys
I think I have found another bug in the column chooser. I have a set of columns, some of which have 'hidedlg' activated so that they cannot be chosen / unchosen by the user. This works until I load new data in using 'setGridparam'. When I do this, the only columns shown are the ones the user has chosen.
In case this isn't clear, an example. I have a table with 'name', 'town' and 'country' in it. the user can choose to display the town or the country, but the name is always there. i.e
colModel:[
{name:'id',index:'id', width:20,hidden:true,hidedlg:true},
{name:'name',index:'name', width:120,hidedlg:true},
{name:'town',index:'location1', width:80},
{name:'country',index:'location3', width:20}
]
so the user can choose to display country or town, but id is always hidden and name is always visible.
However, when I run setGridParam and load new data from a script, it gets very confused indeed.
I don't know if this is exactly a bug or something that I should just not be doing? I should say it worked perfectly until I started using the 'hidedlg' option.
00:54
30/07/2009
My guess is you're doing something wrong... but without know which params you're setting with setGridParam its hard to know.
The thing to be aware of is that when you reorder the columns, they are reordered in the colModel itself. The grid keeps a record of the permutation of the columns, and when you request data from the server, it re-orders it based on that permutation before loading it into the grid (at least, in the repeatitems:true case - for repeatitems:false the order of the data is irrelevant).
So if you use setGridParam to replace the colmodel, for example, bad things are going to happen (unless you are very careful).
Also, if you try to load data into the grid programatically (and not via addJSONData or addXMLData), yuo will have to take account of the new column order.
Finally, if you're just trying to show/hide columns, and dont want them to be re-ordered at all, you can replace the "done" function in the column chooser with a no-op.
Mark
15:53
24/07/2009
Thanks for the swift reply.
I am loading JSON data from a separate URL using setGridParam which then triggers a grid reload. I don't use setGridParam to change the structure of the main grid – the idea is that all the data is in the JSON, including anything that is not visible. So the JSON data stream always contains every column, hidden or otherwise – I did this thinking it would be easiest as I would not have to change the grid structure, simply give the user the option of viewing columns.
When I do basic reloads like this, the data does appears correctly, even after the user makes a column viewing selection. However, if I use the column selection option after the data has been reloaded following a column selection, it gets very confused. It's like the column selector has lost its way and doesn't know what order the columns are in. The names of the columns and the actual references to the columns themselves appear to have become mixed - 'name' appears as a selectable option even though its 'hidedlg' is set to true, and when you select it, it display the 'country' column.
Are you saying that if the user chooses to hide a column, this effectively changes the grid structure – the column is not simply hidden, it's not part of the structure? I guess this would explain it. I'll keep experimenting but your input on how to avoid this would be invaluable, thank you.
Most Users Ever Online: 715
Currently Online:
108 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