Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by JP on Mar 28, 2009 10:29
open dhtmlx forum
stat_total issue

Hi,

I have a grid with 2 auto-calculated columns in the footer and i attached the following onEditCell event:

function onEditCellObjetivo(stage, id, columna, valorNuevo, valorViejo)
{
    if (stage == 1 && gridObjetivo.editor && gridObjetivo.editor.obj) {
        gridObjetivo.editor.obj.select();
    }
    
    if (stage == 2 && (columna == 2 || columna == 4) && valorNuevo != valorViejo) {
        if (valorNuevo < 0 || valorNuevo > 100) {
            alert('Error');
            return false;
        }
    }
    return true;
}

This is only a validation for values between 0 and 100 in columns 2 and 4, however the problem is when i enter a number out of that range, for example 200, the alert shows the error and value is returned to the original old value, but in the footer the autocalculation value uses 200 to recalculate giving me a wrong total. Is this a bug or am i doing something wrong?

By the way, I'm using dhtmlxTreeGrid_v20_pro_81009.

Thanks in advance

Answer posted by dhxSupport on Mar 30, 2009 08:11

This bug confirmed and we'll work on fix it. As a quick solution try to use following code:

function onEditCellObjetivo(stage, id, columna, valorNuevo, valorViejo) 

  if (stage == 1 && gridObjetivo.editor && gridObjetivo.editor.obj) { 
  gridObjetivo.editor.obj.select(); 
  } 
   
  if (stage == 2 && (columna == 2 || columna == 4) && valorNuevo != valorViejo) { 
  if (valorNuevo < 0 || valorNuevo > 100) { 

  window.setTimeout(function(){gridObjetivo.callEvent("onGridReconstructed",[]); },1)
  alert('Error'); 
  return false; 
  } 
  } 
  return true; 
}