Forum



06:24

13/01/2010

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 = " ";
}
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?
14:28

10/08/2009

You should implement custom unformatter always together with the custom formatter. It seems to me that it will solve your problem.
Best regards
Oleg
21:39

13/01/2010

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?
02:29

23/08/2012

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.
Most Users Ever Online: 715
Currently Online:
50 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