Categories | Question details Back To List | ||
How to change cell background color with an ajax validation (in async mode) Hi, I want to change the background color of cell on editing depending on the result of an async ajax call. I've link onEditCell event to my grid and I can make it work using a sync ajax call. But it slows down the grid performance. if(stage == 2 && ind == 0) //valiation numero serie { var loader = dhtmlxAjax.getSync("ajax/dsi_verif_numserie_existe.php?sNumeroSerie="+value); if(loader.xmlDoc.responseText == "true") gridNumeroSerie.cells(id,ind).cell.style.backgroundColor = 'red'; else gridNumeroSerie.cells(id,ind).cell.style.backgroundColor = ''; } I'd like to use a async ajax call to do the same but I don't know how to pass the cell id and index to the ajax response function so that I can set the cell background color depending on the responseText of the loader object. Answer posted by Support on Nov 18, 2008 02:24 Actually it is pretty simple, due the javascript nature, the local variables will be locked in "after-load" function scoope, so you need not any special steps if(stage == 2 && ind == 0) //valiation numero serie { dhtmlxAjax.get("ajax/dsi_verif_numserie_existe.php?sNumeroSerie="+value,function(loader){ //all incoming parameters of above event still available here if(loader.xmlDoc.responseText == "true") gridNumeroSerie.cells(id,ind).cell.style.backgroundColor = 'red'; else gridNumeroSerie.cells(id,ind).cell.style.backgroundColor = ''; }); } |