EasyUI Forum
November 05, 2025, 04:07:31 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How can I set the focus on a datagrid cell that has validation error  (Read 11242 times)
Stefan B.
Full Member
***
Posts: 152


Software Architekt


View Profile Email
« on: March 02, 2015, 03:51:36 AM »

When I will save a row and there is a roq validation error.
How can I set the focus on the first datagrid cell that has validation error?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: March 03, 2015, 08:22:06 PM »

Please extend a new method to achieve this functionality.
Code:
$.extend($.fn.datagrid.methods, {
    focusInvalidField: function(jq, index){
        return jq.each(function(){
            var target = this;
            var tr = $.data(target, 'datagrid').options.finder.getTr(target, index);
            if (!tr.hasClass('datagrid-row-editing')){
                return true;
            }
            var invalidbox = tr.find('.validatebox-invalid');
            invalidbox.filter(':not(:disabled):first').focus();
        })
    }
})

Usage example:
Code:
var index = 2;
$('#dg').datagrid('focusInvalidField', index);
Logged
Stefan B.
Full Member
***
Posts: 152


Software Architekt


View Profile Email
« Reply #2 on: March 05, 2015, 12:36:09 AM »

Hello and thx for this sollution. It works fine  Cheesy
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!