EasyUI Forum
June 16, 2024, 04:56:52 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: Cell data validation for "cellediting"  (Read 5084 times)
officecode
Jr. Member
**
Posts: 69


View Profile Email
« on: March 17, 2019, 08:04:38 AM »

I set the validation property for each column in the datagrid. Now I want that when the current cell data fails validation, other cells cannot enter the edit by clicking.

I did this with the following code:

Code:
var editcell;
$('#dg').edatagrid({
       //........
onBeforeCellEdit:function(index,field){
if(editcell != undefined){
$(this).datagrid('editCell',editcell);
return false
}
},
onCellEdit:function(index,field){
editcell = $(this).datagrid('cell');
},
onEndEdit:function(index,row){
editcell = undefined;
}
}).edatagrid('disableEditing').datagrid('enableCellSelecting').datagrid('enableCellEditing')


This seems to have achieved the goal. However, when the first column of cells fails validation, although the data returned to it has already met the requirements, I can find it difficult to click and edit other cells. Please help me improve the code, thank you!
Logged
jarry
Administrator
Hero Member
*****
Posts: 2265


View Profile Email
« Reply #1 on: March 17, 2019, 11:57:35 PM »

This is the built-in feature. Please refer to the code below:
Code:
$('#dg').datagrid({
    data: data,
    columns: [[
        {field:'itemid',title:'Item ID',width:100},
        {field:'productid',title:'Product',width:100,
            editor: {
                type: 'textbox',
                options: {
                    required: true
                }
            }
        },
        {field:'listprice',title:'List Price',width:100,align:'right',
            editor: {
                type: 'numberbox',
                options: {
                    precision: 1
                }
            }
        }
    ]]
}).datagrid('enableCellEditing').datagrid('gotoCell', {
    index: 0,
    field: 'productid'
});
Logged
officecode
Jr. Member
**
Posts: 69


View Profile Email
« Reply #2 on: March 18, 2019, 04:05:08 AM »

thanks for the reply. I know the usage of this column attribute. The key now is that I don't want other cells to be selected when validation fails.

As shown below:
Logged
jarry
Administrator
Hero Member
*****
Posts: 2265


View Profile Email
« Reply #3 on: March 18, 2019, 09:25:25 AM »

Please look at this example http://code.reloado.com/igerod3/edit#preview. When the validation fails, it doesn't allow to edit other cells.
Logged
officecode
Jr. Member
**
Posts: 69


View Profile Email
« Reply #4 on: March 18, 2019, 05:06:15 PM »

Please look at this example http://code.reloado.com/igerod3/edit#preview. When the validation fails, it doesn't allow to edit other cells.

Thank you, jarry, you have given me a lot of help, thank you very much!
I saw this example and it really is fine. The problem is that if you change the datagrid to edatagrid, it doesn't work: it will still go into editing when you click on another row or other cell.
I now want to use cell-editing in edatagrid, because edatagrid has saveUrl, updateUrl and other attributes, it is more convenient.
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!