EasyUI Forum
December 14, 2024, 02:35:47 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: Datagrid => howto mouve a row on the top of datagrid after an event  (Read 8586 times)
acreonte82
Jr. Member
**
Posts: 85



View Profile
« on: May 26, 2020, 01:21:44 PM »

Hello to all,
I have a singular problem to solve, hope someone can help me to find a right way.
The problem is: i've a datagrid with some rows. Afert the user find an idValue  typed on a text box, if the idValue exists in the datagrid , the row will be mouved on the top  (row number 1) of the datagrid. It's not a drag and drop function, but similar for the final result

Someone can help me?
Thanks
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: May 27, 2020, 12:36:29 AM »

Remove the specified row and then insert it again to where you want. The code below shows how to move a selected row to the top.
Code:
var dg = $('#dg');
var row = dg.datagrid('getSelected');
var index = dg.datagrid('getRowIndex', row);
if (index > 0){
  dg.datagrid('deleteRow', index);
  dg.datagrid('insertRow', {index:0,row:row})
}
Logged
acreonte82
Jr. Member
**
Posts: 85



View Profile
« Reply #2 on: May 27, 2020, 06:08:50 AM »

Thanks stoworthy,
elegant solution as ever!
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!