oneditcell reverts new value to old value

Hi



I have a dhtmlxgrid that is being created from an html table.Code is below.



What is happening is that the inclusion of the event function for onEditCell causes the new value that has been entered to be replaced with the old value.



If i remove the event function completely, the values are updated and displayed as expected.



couple of bits to explain…



the propertyarray is being used to marry up a cell with an ident that i am using in my ajax call.

colSort will be a combination of str,int or date.

colVal will be a combination of ed, calck and dhxCalendarA

I have a button elsewhere on the form that allows the user to copy the whole grid to the clipboard as a csv.



inclusions…





























Now the actual grid code…



var propertyArray=new Array(<%=columnListSB.toString()%>);

var grid=new dhtmlXGridFromTable(“QueryResults”);

//grid.init();

grid.setSkin(“dhx_skyblue”);

grid.enableCellIds(true);

grid.enableSmartRendering(true);

grid.setImagePath("/js/dhtmlxGrid/codebase/imgs/");

grid.enableAutoWidth(true);

grid.enableAutoHeight(true);

grid.setColSorting("<%=colSort.toString()%>");

grid.setColTypes("<%=colVal.toString()%>");

var cl=0;

var propertyTypeStr=‘ro,ro’;

grid.setDateFormat("%d/%m/%Y");

grid.setNumberFormat("$0,000");

grid.enableCSVHeader(true);

grid.csv.cell="\t";

grid.attachEvent(“onEditCell”,function(stage,rId,cInd,newValue,oldValue)

{

if(stage==0)

{

grid.editCell();

}

if(stage==2 && oldValue!=newValue)

{

grid.editStop();

grid.cellById(rId, cInd).setValue(newValue);

grid.selectRow(rId, false, false, true);

grid.setRowColor(rId,“grey”);

var selectProperty=propertyArray[cInd];

var selectContainer= grid.cellById(rId, 0).getValue();

var newValue=escape(newValue);

var oldValue=escape(oldValue);

new Ajax.Request(someurl);

//grid.cellById(rId, cInd).setValue(newValue);



}

}

);



I cant figure out why it isnt working. If i do an alert where the last commented out grid.cellbyid.setvalue call is the cells value is as i would expect. So it seems something is happening after that to revert the value.



Think i am missing something. Help!!

1 Like


onEditCell event handler should return true to confirm editing result. Moreover ther shouldn’t be editCell() call in the stage 0.


grid.attachEvent(“onEditCell”,function(stage,rId,cInd,newValue,oldValue){
/some code here/



return true


})

1 Like