EasyUI Forum
May 16, 2024, 10:44:27 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to highlight(select) the new inserted row in datagrid  (Read 9190 times)
pratikk
Newbie
*
Posts: 49


View Profile Email
« on: May 27, 2015, 01:32:16 AM »

Let's say I have a datagrid which has  more than 100 records. Pagination is true. and pageSize is 10. The first page is showing and the first row is highlighted (selected). After I insert a record  ( This record will be in the 6th page, according to index name ) I want the grid shows page 6 and the new inserted row is highlighted(selected).
« Last Edit: May 27, 2015, 07:09:58 AM by pratikk » Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: May 27, 2015, 08:44:54 AM »

To highlight or select a row, please call 'highlightRow' or 'selectRow' methods. To goto a special page, please get the pagination object and then call 'select' method on it.
Code:
var dg = $('#dg');  // the datagrid
dg.datagrid({
  onLoadSuccess:function(){
    $(this).datagrid('selectRow', rowIndex);
  }
});
var pager = dg.datagrid('getPager');  // the pagination object
pager.pagination('select', pageIndex);  // goto special page
Logged
pratikk
Newbie
*
Posts: 49


View Profile Email
« Reply #2 on: May 27, 2015, 09:03:28 AM »

I don't know the page which the new row will be in.

I used the function below , but it only gets the data of the first ten rows. How can I search the whole data ?

        function findIndex(gelen) {
            var rows = $("#dg_smart").datagrid("getData").rows;
            for (var i = 0; i < rows.length; i++) {
                if (rows["otonum"] == gelen) {
                    return i;
                }
            }
            return -1;
        }

Maybe I can do it on the PHP side, by searching the index ( the index order is by name) of the last added row and then divide id to pageSize to find the page & etc. But if there is a simple way on the client side I want to use it.

There is also another problem finding the proper index. It could be asc or desc or more than one column  can be sortable Huh
« Last Edit: May 27, 2015, 10:17:37 AM by pratikk » 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!