EasyUI Forum
April 30, 2024, 08:35:22 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: [SOLVED] Swap rows in datagrid  (Read 1111 times)
Wojak
Newbie
*
Posts: 48


View Profile Email
« on: October 05, 2023, 03:28:17 PM »

Hi,
I would like to add a button that allows the rows to be swapped up and down. I found a post from 2014, but it doesn't work Sad

https://www.jeasyui.com/forum/index.php?topic=3634.0

Snippet of the code
Code:
function dgSwapColumns(from, to) {
      $('#dg).datagrid('moveRow', { from: from, to: to });
}

It gives me this error
Code:
Uncaught TypeError: $.fn.datagrid.methods[_8ee] is not a function
    at $.fn.datagrid (<anonymous>:12356:35)
    at dgSwapColumns ((index):89:30)
    at HTMLAnchorElement.onclick ((index):1:1)
« Last Edit: October 16, 2023, 09:13:45 AM by Wojak » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: October 14, 2023, 06:14:00 PM »

This code shows how to swap two rows in a datagrid.
Code:
var index1 = 2;
var index2 = 3;
var dg = $('#dg');
var rows = dg.datagrid('getRows');
var temp = rows[index1];
rows[index1] = rows[index2];
rows[index2] = temp;
dg.datagrid('refreshRow',index1);
dg.datagrid('refreshRow',index2);
Logged
Wojak
Newbie
*
Posts: 48


View Profile Email
« Reply #2 on: October 16, 2023, 09:13:30 AM »

Thanks for advice  Wink

Works like a glove
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!