Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by F.Bockelee on May 11, 2009 10:40
open dhtmlx forum
Dynamic change of footer style

Hi,

i try to dynamically change the footer of a grid depnding of the values of the cell

for that, i create a grid withe a footer "total","#stat_total"

i want to test the value and to change it to bold if zero

to do that i create the function (called after loadxml) :

function analyzeFooter() {
    var prefixe='<div class="hdrcell">';
    var postfixe='</div>';

    var zone = mygrid.ftr.rows[1].cells[1].innerHTML;

// suppress div
    var zones = ((zone.split(prefixe))[1].split(postfixe))[0];

    if (zones==0) {
// change format and putting div again
    mygrid.ftr.rows[1].cells[1].innerHTML = prefixe + "<b>" + zones + "</b>" + postfixe;
}
}

As soon as i change the innerHTML, this column stop to be recalculated...and i don't know why

so the aspect is ok (in bold) , but changing a value in the grid don't recalc the footer (on this column only : the others are correct)

even if i put the same value in innerHTM, the footer of the column stop to be recalculed.

have you an idea ?

PS : i try to use the onStatReady event, but this event is not column dependant : it is launched for every column but no way to know which column.

thanks a lot if you have an idea (i have the pro version 2.1 - custId: 141915265)






Answer posted by dhxSupport on May 12, 2009 05:35
If your case better to implement custom autocalculated counter. http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Custom_stat_counters.html#grid_art_custstat
grid._in_header_stat_summ=function(tag,index,c){ // shortcut for statistics counter
  var calck=function(){ // define the function which will be used for calculations
  var summ=0; // set initial counter value
  this.forEachRow(function(id){ // for each row
  summ+=this.cells(id,index).getValue(); // add row_value
  })
  if (!summ) return "<strong>"+summ+"</strong>";
else  return summ;

  }
this._stat_in_header(tag,calck,index,c); //call default statistics handler processor
}

Answer posted by F.Bockelee on May 12, 2009 06:06
OK, that's work fine and is clearly better.

Thanks a lot and congratulations for your support