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
How to getCell value from custom formatter
17/09/2010
06:24
Avatar
msshushu
Member
Members
Forum Posts: 15
Member Since:
13/01/2010
sp_UserOfflineSmall Offline

Hi there,

I am trying to determine if this is even possible. Been agonizing over this for hours. I have a custom formatter as follows:

function linkFormatter(cellvalue, options, rowObject)
{
    if (cellvalue != "") {
        // index of rowObject array is hard coded, keep in mind when column positions change
        newUrl = "<a href='dispform.aspx?ID="+rowObject[29]+"' target=_blank>"+cellvalue+"</a>";
    } else {
        newUrl = "&nbsp;";
    }
    
    return newUrl;
}

Basically, I don't want to keep having to reference an index for the columns, because I'm frequently being asked to change column orders and I sometimes forget to update the custom formatters and it really messes things up. Is there anyway I can use either rowObject or some other method like getCell to access a given column?

I've tried this and it always returns false, I have no idea what false even means.

var rowInfo = $("#backlog").jqGrid('getCell', options.rowId, 'Title');
    
alert(rowInfo);

Is what I'm trying to do even possible?

17/09/2010
14:28
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

You should implement custom unformatter always together with the custom formatter. It seems to me that it will solve your problem.

Best regards
Oleg 

17/09/2010
21:39
Avatar
msshushu
Member
Members
Forum Posts: 15
Member Since:
13/01/2010
sp_UserOfflineSmall Offline

Hi Oleg,

I appreciate the response, but I'm not sure how the unformatter will solve my problem. Basically whether I use an unformatter or a formatter, how do i get another cell's value from within the formatter? the options object returns the information for the column it's applied to.

So if i apply a formatter to the Title column in the colModel, how do I access let's say the Manager cell?

Unless I'm not understanding something, is there someway that the options object contains the info I need?

17/09/2010
22:34
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

The function getCell use formatter to get the value. The formatter test whether the unformatter are defined (whether unformat exist) and if it is defined it use the value returned by your custom unformatter. So just try to do what I suggested. It should work.

Regards
Oleg 

23/08/2012
02:29
Avatar
mb_iceman
New Member
Members
Forum Posts: 1
Member Since:
23/08/2012
sp_UserOfflineSmall Offline

msshushu,

I don't think OlegK understands what you're asking for. I've encountered the same issue as you too.

My solution was to generate my own map of field name to column index as part of initialising my grid.

Rough JS psuedocode:

grid = jQuery("#grid").jqGrid({colModel:myColModelCallback });

myColModelCallback {

colModel = [{name:'col1'},{name:'col2'}];

global var colModelMapping = {};

colModel.each(function(index,value) {

  colModelMapping[value.name] = index;

});

return colModel;

}

So after the grid is initialised but before it has applied the formatters I can now use this global variable colModelMapping like so:

function myFormatter(cellvalue, options, rowObject) {

  console.log('Value of col2 is: ' + rowObject[colModelMapping['col2']]);

}

Hope this helps, its not an ideal situation as far as I'm concerned, jqGrid should really let us get to other cell values in a much more robust manner.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
18 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