Forum


13:05

10/11/2009

Hi,
I am trying to customize jqgrid into my project. What I wish to accomplish here is to define the grid the following way:
………………………
colModel: getColNames('<%= ViewData["myColsNames"] %>'),
colModel: getColModel(”'<%= ViewData["myColsNames"] %>'”),
……………………….
where the getColNames will return an array of strings with the column names that I saved in the view data and the getColModels returns similar array of strings in the format of
{name: 'act', index: 'act', width: 75, sortable: false },
…
When calling the colNames alone with hardcoded colModel, the table looks fine. But when I try using getColModels, it does not work and give an error messsage “length of colName <> colModel”. . I wonder how could I make the grid take the dynamically defined colModel?
Currently the getColModel procedure look like the following:
function(myinput){
//I am mocking up just one column in the table with the corresponding colName set to only one colmn
var t = “{name:” + “\\'Act\\',” + ” index: ” + “\\'Act\\'}”;
return t;
}
Do you have any idea how I could get over with this? I see that colModel is an array of objects. can I defined it on my own colModel dynamically like this?
Any help or comment is appreciated. Thank you!
Ellen
07:34

Moderators
30/10/2007

Hello,
Sorry but I do not understand what you exactley mean with dynamic colModel.
If you want this to happen after every request - i.e. after you use pagging sorting and etc., this is not possible.
The type of error definetley say that you have diffrent definition of colModel and colNames.
In order to solve this problem, you can remove the colNames definition from grid parameters and use the label attribute in colModel something like this.
....
var t = "{label: \\"Mylabel\\" name:" + "\\'Act\\'," +" index: " + "\\'Act\\'};
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:
64 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