EasyUI Forum
April 28, 2024, 05:55:42 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Row Editing in DataGrid + modify all values  (Read 1015 times)
rezzonico
Full Member
***
Posts: 182


View Profile
« 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


« Last Edit: February 17, 2023, 10:07:15 AM by rezzonico » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 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');
}
}
Logged
rezzonico
Full Member
***
Posts: 182


View Profile
« Reply #2 on: February 21, 2023, 07:56:18 AM »

Thanks !

Regards
Miche
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!