Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by gr on Jun 26, 2007 03:08
open dhtmlx forum
OnCellChanged event handler

Im using a OnCellChanged event handler. Inside of this handler I need to validate the new data comparing it with other cells. If the new value is incorrect I need to delete  the newValue (mygrid.cell(rowId,cellIndex).setValue("")), but this action generates an infite iteration (the handler is called infinite times). Is there any function that I can use to solve this problem? OnEditCellHandler is not usefull cause the cell is filled outside the grid without the cell editor.
Answer posted on Jun 26, 2007 13:04
The OnCellChanged is only event which react on direct cell data changing

You have three ways to solve problem

a) Complex and solid - create a custom excell
    You can create a custom excell ( modify an existing one ) where necessary logic will be implemented exactly in setValue method

b) Mediocre - use some kind of flag

    grid.attachEvent("onCellChanged",function(){
          if (!window.skipNextTime){
                window.skipNextTime=false;
                ... //any code here which can initiate onCellChanged event, because of flag, it will be skiped on next processing
                window.skipNextTime=false;
          }
    });

c) Fast and dirty - direct assign
    You can assign HTML value directly to DOM, this will not include possible text procession, but may work for simple editors
       grid.cells(i,j).cell.innerHTML="";

Answer posted by Andrei (Support) on Dec 11, 2014 01:27

To find more precise comments upon this issue, we can offer you read about javascript component framework and attachevent onchange.