EasyUI Forum
June 30, 2024, 01:01:29 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: validType + combogrid  (Read 6931 times)
rezzonico
Full Member
***
Posts: 186


View Profile
« on: October 19, 2015, 07:18:18 AM »

Hi all,

I have a edatagrid with two fields.
The first field is a "combogrid", the second field is a "validatebox".
On both fields I use "validType" with remote option:
validType: 'remote["/cgi-bin/dovalidate.cgi", ""]'
All works as expected.
The only problem is that on "combogrid" the program "dovalidate.cgi" is executed twice.
Is it possible to avoid this ?
Is it allowed to use "validType" with a "combogrid" ?

Here the code:
http://195.144.40.170/EEE/index.html

Thanks for any help.
Miche
« Last Edit: October 19, 2015, 07:25:50 AM by rezzonico » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: October 19, 2015, 07:25:50 PM »

Please try to use the async 'remote' validate type instead.
Code:
(function($){
$.extend($.fn.validatebox.defaults.rules, {
remote: {
validator: function(value, param){
var target = this;
if (target.result == undefined){
target.result = true;
}
if (!target.validated){
target.validated = true;
var data = {};
data[param[1]] = value;
$.ajax({
url: param[0],
data: data,
async: true,
cache: false,
success: function(data){
if ($(target).parent().length){
target.result = (data == 'true');
$(target).validatebox('validate');
}
},
complete: function(){
target.validated = false;
}
});
}
return target.result;
},
message: 'Please fix this field.'
}
})
})(jQuery);
« Last Edit: October 20, 2015, 01:27:47 AM by stworthy » Logged
rezzonico
Full Member
***
Posts: 186


View Profile
« Reply #2 on: October 20, 2015, 01:06:08 AM »

Hi stworthy,

thanks a lot for your help.
After adding your code the program is executed only once but I see two other problems:

1) When I click on the field the message "Please fix this fileld" appears for a short time, even if the program "dovalidate.cgi" return "true".
You can see this selecting the following link:
http://195.144.40.170/EEE/index.html


2) When (after selecting the first line) I select the second line, the error "TypeError: _48d is undefined" appears.

Is it possible to fix these two problems ?

Thanks
Miche
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: October 20, 2015, 01:29:39 AM »

You can modify the async 'remote' validator freely to meet your requirement. Please refer to the updated code above.
Logged
rezzonico
Full Member
***
Posts: 186


View Profile
« Reply #4 on: October 21, 2015, 12:39:16 PM »

Hi stworthy,

it works perfectly !

Thanks
Miche
« Last Edit: October 21, 2015, 12:40:54 PM by rezzonico » 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!