EasyUI Forum
July 02, 2024, 08:55:13 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: The rows that have been deleted in the datagrid, how to restore them again?  (Read 4828 times)
officecode
Jr. Member
**
Posts: 69


View Profile Email
« on: December 01, 2018, 10:51:56 PM »

I tried multiple methods like loadData and it won't work.
Please help, thank you!

Code:

var rows = $('#test').datagrid('getChanges','deleted');
//How to restore them again?

« Last Edit: December 02, 2018, 07:17:54 PM by officecode » Logged
officecode
Jr. Member
**
Posts: 69


View Profile Email
« Reply #1 on: December 02, 2018, 07:09:34 PM »

I tried using the code below, but there is no way to reload only on the current page:

Code:
var dt = $('#test').datagrid('getRows');
var delrows = $('#test').datagrid('getChanges','deleted');
$('#test').datagrid('loadData',dt.concat(delrows));
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: December 02, 2018, 07:24:09 PM »

After calling the 'deleteRow' method to delete a row, you can call 'rejectChanges' method to restore the data. If the 'acceptChanges' method is called, you will lost the deleted rows.
Logged
officecode
Jr. Member
**
Posts: 69


View Profile Email
« Reply #3 on: December 02, 2018, 10:03:16 PM »

After calling the 'deleteRow' method to delete a row, you can call 'rejectChanges' method to restore the data. If the 'acceptChanges' method is called, you will lost the deleted rows.

I know the usage of 'rejectChanges', but after the execution, all the changes will be lost.
Sometimes, I may just want to recover deleted rows.
If the method 'loadData' can add  a page parameter, it would be great!
thank you for your help!
« Last Edit: December 02, 2018, 10:15:16 PM by officecode » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #4 on: December 02, 2018, 11:54:35 PM »

If you can get the deleted rows, please call 'appendRow' or 'insertRow' method to insert them.
Code:
var dg = $('#dg');
var deletedRows = dg.datagrid('getChanges','deleted');
for(var i=0; i<deletedRows.length; i++){
  dg.datagrid('appendRow', deletedRows[i])
}
dg.datagrid('acceptChanges')
Logged
officecode
Jr. Member
**
Posts: 69


View Profile Email
« Reply #5 on: December 03, 2018, 02:07:05 AM »

Haha, why didn't I think of using appendRow? This method is very good, although it may not be the original location after the addition.
Thank you very much, EasyUI is great, the administrator is better.
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!