Categories | Question details Back To List | ||
grid cell with numberFormat and value 0 is null Hello! I have a grid with a column "edn" and numberFomat: ---- gridPrecios.setNumberFormat("0.00 €", 2); ---- I have a row with a value 0 in column "edn". And this event onCellEdit: ---- if (stage == 1 && this.editor && this.editor.obj) { this.editor.obj.select(); return true; } if (stage == 2) { if (gridPrecios.cells(rowId, 2).getValue() == "") gridPrecios.cells(rowId, 2).setValue("0"); alert (gridPrecios.cells(rowId, 2).getValue()); //shows empty string!!!!!!!!! } return true; ---- How can I have a value 0 in this cell and that it shows 0 in function getValue? Thanks! Bye Answer posted by Alex (support) on Oct 20, 2009 05:45 Hello, insetad of if (gridPrecios.cells(rowId, 2).getValue() == "") gridPrecios.cells(rowId, 2).setValue("0"); you can use the following approach: if (gridPrecios.cells(rowId, 2).getValue() == "") return "0.0"; Please, see the http://www.dhtmlx.com/dhxdocs/doku.php?id=dhtmlxgrid:event_oneditcell page for more details. Answer posted by Rachel Santamaría on Oct 20, 2009 07:31 This is a bad solution because I have to validate more cells and I can't return at this moment. I need to put 0 in this cell and continue with calculations...
Answer posted by Alex (support) on Oct 20, 2009 07:51 The provided approach is the only way to set custom value right after the editor is closed. What calculation do you want to execute ? Possibly it can be done before return command. Answer posted by Rachel Santamaría on Oct 20, 2009 07:57 This is my code: ---- gridPrecios.attachEvent("onEditCell", function(stage, rowId, cellInd, newValue, oldValue){ ---- Answer posted by Alex (support) on Oct 20, 2009 08:08 In this case you can get value once, put it in some variable and manipulate with it. There is no need to call setValue and getValue methods sevaral times. Answer posted by Rachel Santamaría on Oct 20, 2009 08:20 I remember that if in the oncelledit event didn't return "true", something failure. Can I be? Answer posted by Alex (support) on Oct 20, 2009 08:42 This event can return true(1), false(0) or some other value. Please, see details here: http://www.dhtmlx.com/dhxdocs/doku.php?id=dhtmlxgrid:event_oneditcell |