EasyUI Forum
December 21, 2025, 11:43:26 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 SelectRow issue.  (Read 14858 times)
fonzie
Newbie
*
Posts: 9


View Profile
« on: May 02, 2017, 01:10:13 AM »

I want to be able to highlight (eg select) the same row in a datagrid after reloading the data (eg after saving a change in a form).

If I DON'T call 'reload' (which I need to do to display the changes made on a form) I can select a row by calling 'selectRow', but if DO call 'reload', no row is selected.  Is there a workaround ?, is this a bug?, am I doing something wrong? .

Here is the code I'm using :-

var row = $('#dg').datagrid('getSelected');
var index = $('#dg').datagrid('getRowIndex', row);
   
$('#dg').datagrid('reload');   // reload the user data
$('#dg').datagrid('selectRow', index);

Thank you in advance for any assistance.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: May 02, 2017, 01:16:47 AM »

Please set the 'idField' property for the datagrid.
Logged
fonzie
Newbie
*
Posts: 9


View Profile
« Reply #2 on: May 02, 2017, 01:53:25 AM »

Thank you so much, that now works perfectly.

For anyone else who has this issue, here is how I implemented it :


<table id="dg" title="text here" class="easyui-datagrid" style="width:1500px;height:100%"
   
    data-options="
         url:'./support_files/get_users.php',
         toolbar:'#toolbar',
         pagination:true,
         rownumbers:true,
         fitColumns:true,
         singleSelect:true,
            idField:'ID',
           onClickRow:function(){
            showUser();
         }
      " >
   
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!