EasyUI Forum
April 27, 2024, 06:02:09 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: datagrid + validtype  (Read 3474 times)
rezzonico
Full Member
***
Posts: 182


View Profile
« 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
« Last Edit: March 28, 2018, 04:35:42 AM by rezzonico » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 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});
}
}
})
Logged
rezzonico
Full Member
***
Posts: 182


View Profile
« Reply #2 on: March 29, 2018, 06:28:29 AM »

Thanks !

Miche
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!