EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: rezzonico on February 17, 2023, 10:03:15 AM



Title: Row Editing in DataGrid + modify all values
Post by: rezzonico on February 17, 2023, 10:03:15 AM
Hi all,

I have a datagrid similar to the example "Row Editing in DataGrid".
https://www.jeasyui.com/demo/main/index.php?plugin=DataGrid&theme=default&dir=ltr&pitem=Row%20Editing%20in%20DataGrid

I want to add a button that in one step can change all the row values of the column "Status" at once.
My idea is to loop through the rows, change into editmode and modify the value of the column "Status".

Is this a correct approach ?

Any help is appreciated.

Regards
Michelangelo




Title: Re: Row Editing in DataGrid + modify all values
Post by: jarry on February 19, 2023, 11:34:46 PM
You can call 'updateRow' method for all rows except the editing row. Here is the code that demonstrates how to achieve this functionality.
Code:
var dg = $('#dg');
dg.datagrid('getRows').forEach(row => {
var index = dg.datagrid('getRowIndex', row);
if (index != editIndex){
dg.datagrid('updateRow', {
index: index,
row: {status: value}
});
}
});
var editor = dg.datagrid('getEditor', {index:index,field:'status'});
if (editor){
if (value){
$(editor.target).checkbox('check');
} else {
$(editor.target).checkbox('uncheck');
}
}


Title: Re: Row Editing in DataGrid + modify all values
Post by: rezzonico on February 21, 2023, 07:56:18 AM
Thanks !

Regards
Miche