Categories | Question details Back To List | ||
Custom onEditCell Event function does not store new value Hi, I try to store the new value in my cell. This is my simple funtion function doOnCellEdit(stage,rowId,cellInd,newVal,oldVal){ if(stage==0){ return true; } if (stage == 1) { return true; } if (stage == 2) { this.cells(rowId, cellInd).setValue(newVal); alert(this.cells(rowId, cellInd).getValue()); alert(oldVal); } } I `m using mutiple grids with this for loop : for (var i = 0; i < g_xmlDataTablesString.length; i++) { rawGridArray[i] = new dhtmlXGridObject("" + g_xmlDataTablesString[i] + ""); rawGridArray[i].setEditable(true); rawGridArray[i].attachEvent("onEditCell", doOnCellEdit); rawGridArray[i].setImagePath("codebase/imgs/"); rawGridArray[i].init(); rawGridArray[i].loadXML("" + "../" + g_xmlDataTablesString[i] + ".xml" + ""); rawGridArray[i].setSkin("light"); rawGridArray[i].enableLightMouseNavigation(true); } My xml file for initialization (filled with sample data) <?xml version="1.0" encoding="UTF-8"?> <rows total_count="10"> <head> <column type="ro" sort="str" width="70">Rechner</column> <column type="ed" sort="int" width="70">64</column> <column type="ed" sort="int" width="70">128</column> <column type="ed" sort="int" width="70">256</column> <column type="ed" sort="int" width="70">512</column> <column type="ed" sort="int" width="70">1024</column> <column type="ed" sort="int" width="70">2048</column> <column type="ed" sort="int" width="70">4096</column> <column type="ed" sort="int" width="70">8192</column> <beforeInit> <call command="enableResizing"> <param>false,true,true,true,true,true,true,true,true</param> </call> </beforeInit> </head> <row id="1"> <cell>pc01</cell> <cell>8762</cell> <cell>9223</cell> <cell>9148</cell> <cell>10136</cell> <cell>10317</cell> <cell>10498</cell> <cell>10975</cell> <cell>11068</cell> </row> <row id="2"> <cell>pc02</cell> <cell>8044</cell> <cell>9065</cell> <cell>8387</cell> <cell>10129</cell> <cell>10559</cell> <cell>10735</cell> <cell>10974</cell> <cell>11046</cell> </row> <row id="3"> <cell>pc03</cell> <cell>7421</cell> <cell>9393</cell> <cell>8289</cell> <cell>10084</cell> <cell>10192</cell> <cell>10807</cell> <cell>10929</cell> <cell>11088</cell> </row> <row id="4"> <cell>pc04</cell> <cell>7380</cell> <cell>7363</cell> <cell>9717</cell> <cell>8420</cell> <cell>10061</cell> <cell>9983</cell> <cell>10816</cell> <cell>10673</cell> </row> <row id="5"> <cell>pc05</cell> <cell>7347</cell> <cell>8212</cell> <cell>5262</cell> <cell>7921</cell> <cell>10335</cell> <cell>10063</cell> <cell>10870</cell> <cell>10941</cell> </row> <row id="6"> <cell>pc06</cell> <cell>6196</cell> <cell>9169</cell> <cell>5143</cell> <cell>7747</cell> <cell>9500</cell> <cell>8959</cell> <cell>10815</cell> <cell>11112</cell> </row> <row id="7"> <cell>pc07</cell> <cell>8057</cell> <cell>5745</cell> <cell>8065</cell> <cell>9127</cell> <cell>9605</cell> <cell>9978</cell> <cell>10245</cell> <cell>10504</cell> </row> <row id="8"> <cell>pc08</cell> <cell>6322</cell> <cell>5143</cell> <cell>8914</cell> <cell>7045</cell> <cell>8026</cell> <cell>10712</cell> <cell>9409</cell> <cell>10515</cell> </row> <row id="9"> <cell>pc09</cell> <cell>8179</cell> <cell>8440</cell> <cell>9696</cell> <cell>10254</cell> <cell>10533</cell> <cell>10716</cell> <cell>10870</cell> <cell>11025</cell> </row> <row id="10"> <cell>pc10</cell> <cell>7658</cell> <cell>9310</cell> <cell>9773</cell> <cell>8604</cell> <cell>10370</cell> <cell>10814</cell> <cell>10977</cell> <cell>10797</cell> </row> </rows> Grid initialization works so far, but after editing a cell the value gets resetted imidiately to the old value. Why ? If I do not handle the onCellEdit event with my function, the new value is "saved" to the grid. So what I`m doing wrong here ? Thanks, Andreas Answer posted by Support on Nov 04, 2008 03:21 >>Grid initialization works so far, but after editing a cell the value gets resetted imidiately to the old value. Why ? You not returning "true" after setting new value, grid treat it as a signal to block edit operation and revet cell to old value if (stage == 2) { this.cells(rowId, cellInd).setValue(newVal); return true; } |