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
How to handle dynamic colModel ?
19/11/2009
13:05
Avatar
ellenecho
Member
Members
Forum Posts: 3
Member Since:
10/11/2009
sp_UserOfflineSmall Offline

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

21/11/2009
07:34
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Sofia

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.com

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

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information