Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Andres on Jan 11, 2010 05:40
open dhtmlx forum
DhtmlxGrid - Validations

Hello,

I'm using DhtmlxPRO version.

We are useing XML serialized grid, to send/receive information to the server.
I need to have some client side validations (mostly not empty, and data types).

We are actually using:

myGrid.enableValidation(true,true,true,);
myGrid.setColValidators("NotEmpty,NotEmpty,");

And works correctly, but I have 2 questions:

1) With this example, can I add more than one validation per column? Or are these validations added automatically?
If I want a column NOT to be validate as "NotEmpty" but if some data is inserted, YES to be validated by ValidInteger?

2) I want to use something similiar to Dataprocessor's "checkBeforeUpdate" function,

Like this:

for (var i=0; i<myDataProcessor.updatedRows.length; i++){
valid&=myDataProcessor.checkBeforeUpdate(myDataProcessor.updatedRows[i]);             
}

Can I use anything else in particular, without using DataProcessor?

Thanks in advanced,
Andres
Answer posted by Stanislav (support) on Jan 12, 2010 04:00
>>With this example, can I add more than one validation per column?
Yep, you can use next syntax
myGrid.setColValidators(["NotEmpty,ValidEmail","NotEmpty",""]);

In such case first column will have two validation rules

>>to be validate as "NotEmpty" but if some data is inserted, YES to be validated by ValidInteger
You can use ValidInteger, because it already requires that value must be non-empty

>>2) I want to use something similiar to Dataprocessor's "checkBeforeUpdate" function
var result = true;
grid.forEachRow(function(id){
     if (!grid.validateCell(id, INDEX))
             result=false;
});
Answer posted by Andsres on Jan 12, 2010 05:11
Thanks Stanislav for your response:

Just one more question:

On point 1:
Previous question: "If I want a column NOT to be validate as "NotEmpty" but if some data is inserted, YES to be validated by ValidInteger? "
I want a value to be validated (for example as integer) but ONLY if the data is inserted, This field CAN be empty.

How can I do this?

Thanks in advanced!
Andres

Answer posted by Stanislav (support) on Jan 12, 2010 05:46
It can't be achieved by existing validation rules. But you can implement your own validation function which will check value against empty and after at confirm if it valid integer or not. 

http://dhtmlx.com/dhxdocs/doku.php?id=dhtmlxgrid:validation_extension#defining_custom_rules_for_validation_extension
Answer posted by Andres on Jan 12, 2010 06:15
Ok, Thanks a lot for your responses!