EasyUI Forum
April 18, 2024, 05:17:17 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: Validation in editable datagrid  (Read 1910 times)
galcott
Newbie
*
Posts: 39


View Profile
« on: March 06, 2022, 12:29:25 PM »

I am using the datagrid with the cell editing extension. Initially the grid is empty and I append a bunch of blank rows for the user to enter data. There are 2 columns, and when the user enters data in the first column I need to validate it against a database. The problem is that I can't find any event that's triggered when the user leaves a cell. The extension has an onCellEdit event but that is triggered while the cell is being edited. I need an event that's triggered when the edit is done and returns the value entered. Is there a way to do that?
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: March 09, 2022, 12:22:20 AM »

Please assign a validation type to the cell editor.
Code:
$.extend($.fn.validatebox.defaults.rules, {
    // custom your validation type
    myValidation: {
        validator: function(value, param){
            return value.length >= param[0];
        },
        message: 'Invalid value.'
    }
});
$(function(){
    $('#dg').datagrid({
        columns: [[
            {field:'itemid',title:'Item',width:100,
                editor: {
                    type: 'textbox',
                    options: {
                        required: true,
                        validType: {
                            myValidation: [5]
                        }
                    }
                }
            },
            {field:'productid',title:'Product',width:100,editor:'textbox'}
        ]],
        data: data
    }).datagrid('enableCellEditing').datagrid('gotoCell', {
        index: 0,
        field: 'productid'
    });
});
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!