EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: mapner on December 24, 2017, 01:23:53 PM



Title: Conditional Cell Editing in Datagrid
Post by: mapner on December 24, 2017, 01:23:53 PM
Hi,

How I can set conditional Cell Editing in a Datagrid?
I want enabled to Cell Editing when variable EditForm is true (and disbled when EditForm is false)

thanks


Title: Re: Conditional Cell Editing in Datagrid
Post by: stworthy on December 25, 2017, 12:28:48 AM
Please call 'enableCellEditing' and 'disableCellEditing' methods to enable or disable it.


Title: Re: Conditional Cell Editing in Datagrid
Post by: mapner on December 25, 2017, 03:39:35 PM
Thanks for you reply,

but, how to set conditional edit for one cell depending of the row data?

Example:
Grid for Pay
Column1: Pay Type (CASH, BANK, CREDITCARD, ...)
Column2: Bank Name (if Column1 Type is = 'BANK' set Cell Editing)
Column3: Amount

Best regards





Title: Re: Conditional Cell Editing in Datagrid
Post by: stworthy on December 25, 2017, 05:15:52 PM
Return false in the 'onBeforeCellEdit' to deny the editing action. Please refer to the code below:
Code:
$('#dg').datagrid({
data: data,
onBeforeCellEdit: function(index,field){
var row = $(this).datagrid('getRows')[index];
if (row.Column2 == 'BANK'){
return true;
} else {
return false;
}
}
}).datagrid('enableCellEditing').datagrid('gotoCell', {
index: 0,
field: 'Column1'
});