views:

774

answers:

1

Hello there,

I am new to JqGrid, so please bare with me. I am having some problems with styling the cells when I use a showlink formatter. In my configuration I set up the AfterInsertRow and it works fine if I just display simple text:

 afterInsertRow: function(rowid, aData) {
   if (aData.Security == `C`) {
     jQuery('#list').setCell(rowid, 'Doc_Number', '', { color: `red` });
 } else
 {
   jQuery('#list').setCell(rowid, 'Doc_Number', '', { color: `green` });
 }
}, ...

This code works just fine, but as soon as I add a formatter

{'Doc_Number, ..., 'formatter: ’showlink’, formatoptions: {baseLinkUrl: ’url.aspx’}

the above code doesn't work because a new element is added to the cell

<a href='url.aspx'>cellValue</a>

Is it possible to access programmatically the new child element using something like the code above and change the style? <a href='url.aspx' style='color: red;'>cellValue</a> etc.

Thanks in advance,

oirfc

UPDATE:

In order to work you have to do as follow:

jQuery('#list').setCell(rowid, 'Doc_Number', '', 'redLink');

CSS Class

.redLink a {
    color: red;
}

Thank you Justin for your help.

+2  A: 

You could add a class to the cell:

jQuery('#list').setCell(rowid, 'Doc_Number', '', 'redLink');

Then define a CSS class along these lines:

.redLink a {
    color: red;
}
Justin Ethier
Hi Justin, it doesn't work. Now it display 'redlink' as cell text.
oirfc
Hi again,it actually works if you invert the last two parameters:jQuery('#list').setCell(rowid, 'Doc_Number', '', 'redLink'); Thank you for pointing me in the right direction.
oirfc
Sorry about that, but I'm glad you got it to work! FWIW, I just updated my answer.
Justin Ethier