EasyUI Forum

General Category => General Discussion => Topic started by: acreonte82 on May 26, 2020, 01:21:44 PM



Title: Datagrid => howto mouve a row on the top of datagrid after an event
Post by: acreonte82 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


Title: Re: Datagrid => howto mouve a row on the top of datagrid after an event
Post by: stworthy 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})
}


Title: Re: Datagrid => howto mouve a row on the top of datagrid after an event
Post by: acreonte82 on May 27, 2020, 06:08:50 AM
Thanks stoworthy,
elegant solution as ever!