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_Related Related Topics sp_TopicIcon
Custom Formatter Parameters
29/11/2010
07:10
Avatar
casperd
Member
Members
Forum Posts: 76
Member Since:
11/05/2009
sp_UserOfflineSmall Offline

Hi,

Is it possible to send additional parameters to a custom formatter function?

Thanks,

Cas

30/11/2010
21:32
Avatar
tucano
Rio Grande do Sul - Brasil
Member
Members
Forum Posts: 7
Member Since:
22/10/2010
sp_UserOfflineSmall Offline

não sei se entendi perfeitamente a sua pergunta, mas me tento a responder.

se for algo desse tipo

{myColun: myFunction(param1,param2)}

para o addRowData, funciona sim

até mais!

Laugh

att,nTucano

02/12/2010
06:23
Avatar
casperd
Member
Members
Forum Posts: 76
Member Since:
11/05/2009
sp_UserOfflineSmall Offline

Thanks for the reply. But, I still don;t understand how that will fit into a Custom Formatter function?

02/12/2010
13:09
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hello casperd,

if you post the code example with your custom formatter and explain what which information you want to have additionally in the custom formatter one could explain all more clear.

Best regards
Oleg

14/12/2010
12:47
Avatar
casperd
Member
Members
Forum Posts: 76
Member Since:
11/05/2009
sp_UserOfflineSmall Offline

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

14/12/2010
13:34
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

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 

14/12/2010
13:52
Avatar
casperd
Member
Members
Forum Posts: 76
Member Since:
11/05/2009
sp_UserOfflineSmall Offline

Hi Oleg,

You're the man!! This sorted it out.

Thanks!

Cas

25/09/2012
08:00
Avatar
Copperhead89
New Member
Members
Forum Posts: 1
Member Since:
13/09/2012
sp_UserOfflineSmall Offline

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

Forum Timezone: Europe/Sofia

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

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

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information