Forum



21:32

22/10/2010

12:47

11/05/2009

Hi Oleg,
Here is my current formatter function:
ProjectLink_formatter = function (cellvalue, options, rowObject){
return "<a href='" + rowObject.childNodes[6].textContent + "' target=_new title='Click to navigate to the Project Workspace'>" + cellvalue + "</a>";
}
Now, I would like to replace the hardcoded "6" in the function above with a variable parameter, so that I can use any value. Something like this:
ProjectLink_formatter = function (cellvalue, options, rowObject,iColNum){
return "<a href='" + rowObject.childNodes[iColNum].textContent + "' target=_new title='Click to navigate to the Project Workspace'>" + cellvalue + "</a>";
}
What are the best options?
Thanks,
Cas
13:34

10/08/2009

Hello Cas,
custom formatter is a callback function, like WindowProc for example. So jqGrid will call it and will not know in what calls which value of iColNum should be used. In general the parameters of all callback functions define the caller, so by jqGrid or by Windows, and you should implement the function with the defined parameters if you want to use the feature and not vice versa. Like Microsoft will not rewrite Windows Code for one customer, jqGrid code can not be rewritten for every user. Moreover, like I described at the beginning of my email, jqGrid can not know which value of the additional parameter could be used at the different calls.
If you want to define the function with additional parameter like
you can call it yourself from the custom formatter function of every column where it need be used:
{name:'SecondColumn', formatter: function (cellvalue, options, rowObject) { return ProjectLink_formatter(cellvalue, options, rowObject,3);}}
and so on. So you should call yourself the function which you define.
Best regards
Oleg
08:00

13/09/2012

OlegK said:
Hello Cas,
custom formatter is a callback function, like WindowProc for example. So jqGrid will call it and will not know in what calls which value of iColNum should be used. In general the parameters of all callback functions define the caller, so by jqGrid or by Windows, and you should implement the function with the defined parameters if you want to use the feature and not vice versa. Like Microsoft will not rewrite Windows Code for one customer, jqGrid code can not be rewritten for every user. Moreover, like I described at the beginning of my email, jqGrid can not know which value of the additional parameter could be used at the different calls.
If you want to define the function with additional parameter like
ProjectLink_formatter = function (cellvalue, options, rowObject,iColNum){...}you can call it yourself from the custom formatter function of every column where it need be used:
{name:'FirstColumn', formatter: function (cellvalue, options, rowObject) { return ProjectLink_formatter(cellvalue, options, rowObject,6);}},
{name:'SecondColumn', formatter: function (cellvalue, options, rowObject) { return ProjectLink_formatter(cellvalue, options, rowObject,3);}}and so on. So you should call yourself the function which you define.
Best regards
Oleg
Oh my god, it's worked, thanks you so much
Most Users Ever Online: 715
Currently Online:
49 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