Categories | Question details Back To List | ||
Dataprocessor I have a grid with 2 columns and when a new record is inserted into the grid i would like to force the users to enter a value into the cell of column 2 if the cell value of column 1 is greater than 4. How can i check for this condition on the dataprocessor? Iam also trying to make the column 1 a required field and iam using the following code: myDataProcessor.setVerificator(0,checkIfNotZero) function checkIfNotZero(value,colName){ if(value.toString()._dhx_trim()==""){ alert(colName+" cannot not be empty"); return false; } else { return true;}} The problem is that the checkifNotZero function is being triggered immediately when i insert a new row into the grid. I would like it to be triggered when i hit the save button. Answer posted by Support on Apr 24, 2008 05:19 Built in verificators will run after any row update operation. If you need to run verification before saving only, you can use custom code instead of built in function beforeSave(){ for (var i=0; i<dp.updatedRows.length; i++){ var id=dp.updatedRows[i]; if (id){ if (grid.cells(id,0).getValue()=="") return alert(" cannot not be empty"); if (grid.cells(id,0).getValue() > 4 && grid.cells(id,1).getValue()=="") return alert(" cannot not be empty"); } } dp.sendData(); } Answer posted on Apr 23, 2008 14:46 I tried using the code snippet but iam getting the following error: 'myDataProcessor.updateRows.length' is null or not an object. Answer posted by Support on Apr 24, 2008 05:20 Sorry for inconvenience, it was a typo from my side, the snippet above updated. If it still cause problems for you - please contact us directly at support@dhtmlx.com and provide you reference number, we will send you a working sample. |