Forum


09:00

02/03/2010

I want to show data for a specific project but each project has diiferent number of columns in the table. Knowing which project is to be displayed i can find out how how columns are in the table before grid creation. Is there a way to now set colnames and colmodels dynamically to the number of columns in the project and to get colnames from the database as well.
So if P1 has 2col (A,B) and P2 has 3col (X,Y,Z). so if user chooses P2 from html dropdown and clicks submit i want a grid with 3 col with header x,y,z to be created, likely if they choose p1 the grid shoul have 2col with a,b as headers
Thanks
15:00

Moderators
30/10/2007

Hello,
You can use GridUnload method to destroy the grid an create it again with the new columns smething like
var colmodel1 = …
var colmodel2 = …
$("#myselect").change(function(){
if($(this).val() == "1″) {
$("#mygrid").GridUnload();
$("#mygrid").jqGrid({… colModel: colmodel1,…})
} else if( …) {
$("#mygrid").GridUnload();
$("#mygrid").jqGrid({… colModel: colmodel2,…})
}
});
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.
Most Users Ever Online: 715
Currently Online:
61 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