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.

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();
}

I tried using the code snippet but iam getting the following error: ‘myDataProcessor.updateRows.length’ is null or not an object.

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.