EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: rezzonico on March 28, 2018, 01:43:41 AM



Title: datagrid + validtype
Post by: rezzonico on March 28, 2018, 01:43:41 AM
Hi all,

I have a datagrid with (suppose) 2 columns: col1 and col2

I use validType to validate col2. This works ok.

The problem is that now I need to validate col2 depending from col1 and col2.
Im my program if col2 beginn with 'x' then col1 is required.

Is this possible ?

Thanks for any help.
Miche


Title: Re: datagrid + validtype
Post by: jarry on March 28, 2018, 06:08:55 PM
When beginning to edit a row, retrieve the column editors and set the validation rules on them. The code below shows how to make the 'col1' required when col2 starts with 'x' char.
Code:
$('#dg').datagrid({
onBeginEdit: function(index, row){
var ed1 = $(this).datagrid('getEditor', {index:index,field:'col1'});
if (row.col2.startsWith('x')){
$(ed1.target).textbox({required:true});
}
}
})


Title: Re: datagrid + validtype
Post by: rezzonico on March 29, 2018, 06:28:29 AM
Thanks !

Miche