setCellTextStyle for background colour not working properly

the recursion in your excell is due to the calling the getValue() method from the exCell.
Please, refer to the tutorials about creating a custom exCell to see how you can get the value of a cell and change it’s background.
Here is the working example:

function eXcell_edncl(cell) { this.base = eXcell_edn; this.base(cell); this.setValue = function(val) { // the function containes the value of a cell if (!val || val.toString()._dhx_trim() == ""); val = "0"; if (val >= 0); this.cell.style.color = "green"; //you can change the cell style from that function else; this.cell.style.color = "red"; this.cell.innerHTML = this.grid._aplNF(val, this.cell._cellIndex); } }

Hi Sematik

The example that you referred me to shows me how to ‘SET’ the value of an eXcell but does not show me how to ‘GET’ the value. I tried getting the value using:

  this.cell.innerHTML

But that was all blank. Please can you tell me how to ‘GET’ the value using lower level functions for each cell.

I also tried:

cell.getValue() and this.cell.getValue() but in both cases it said there was no such function.

This is getting very urgent.

Thanks

Hi Sematik

Previously when I tried : this.cell.innerHTML I got blank data. However now all of a sudden it is saying : NS_ERROR_NOT_AVAILABLE

I don’t think I’ve changed anything although I’ve been trying many different things. In particular I’ve been trying various things based on this (docs.dhtmlx.com/doku.php?id=dhtm … le_excells) part of the documentation.

I really need some help here URGENTLY.

Before getting the value from the current rendering cell at first you need to fill some value to it.
So your may get the value right from the setValue function. Also you need to change the style of the cell in that function.

Hi Sematik

Clearly I have not understood something here. The data is being loaded from an xml file. I’m not setting anything manually. All I want to do is compare the val in this cell with a value in another cell in the same row and then set the background colour. The added complication is that this is a ‘link’ type cell.

Ok so I tried this:

      function eXcell_rec(cell)
      {
          this.base = eXcell_link;
          this.base(cell);
          var nxrid = this.cell.parentNode.idd;
          this.setValue = function(val)
          {
              this.cell.innerHTML = this.grid._aplNF(val,this.cell._cellIndex);
              TmpRecVal = this.getValue();
              TmpInvVal = parseFloat(grdInvs.cells(nxrid,InvTotalVal).getValue()).rnd(2);
              TmpRecVal == 0 ? '' : TmpInvVal == TmpRecVal  ? this.cell.style.backgroundColor ='#BDFCC9' : this.cell.style.backgroundColor='#FFC0CB';
          }
          this.getValue = function()
          {
              return this.cell.innerHTML;
          }
      }
      eXcell_rec.prototype = new eXcell;

But now the cell is showing the value as sent by the xml e.g. :
102.00^javascript:showRecpts(165)^_self

Rather than showing it as value 102 with a clickable link. Also this.getValue is therefore returning the full string which is useless.

I have tried to find an example of a ‘link’ eXcell in the documentation to see how setValue function should be written but I can’t find any.

I am really getting quite frustrated with this.

I have tried to find an example of a ‘link’ eXcell in the documentation to see how setValue function should be written but I can’t find any.

You can see how the setValue function is written for the link exCell right in the dhtmlxgrid_excell_link.js

For your issue: You may try to change the style of your row right when it renders in your grid.
You need to use the onRowCreated event:

grdInvs.attachEvent("onRowCreated", function(rId,rObj,rXml){ if(grdInvs.cells(rid,InvType).getValue() == 'Credit Note') { grdInvs.setCellTextStyle(rid,InvType,'color:red'); grdInvs.setCellTextStyle(rid,InvValExcVAT,'color:red'); grdInvs.setCellTextStyle(rid,InvVATVal,'color:red'); grdInvs.setCellTextStyle(rid,InvTotalVal,'color:red'); } });

Hi Sematik

Thanks again for your response. Is onRowCreated event available in V3.0 or only V3.6? Unfortunately your documentation doesn’t make that clear.

Also is this still valid if fast render is on?

Ugh if that is the case then I have wasted so much time for nothing.

Purvez

P.S. I’ll try out what you suggest and see what happens. I only wish you had pointed this out to me earler.

Hi Sematik

I tried the onRowCreated event and it worked perfectly. Is it worthwhile trying to understand what information I could have provided you earlier that would have saved us both a LOT of time trying to go down the eXcell route?

What I want to do is ensure that I know what information to provide you so that so much time is not wasted.

Thanks

Purvez