EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: pratikk on May 27, 2015, 01:32:16 AM



Title: How to highlight(select) the new inserted row in datagrid
Post by: pratikk 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).


Title: Re: How to highlight(select) the new inserted row in datagrid
Post by: jarry 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


Title: Re: How to highlight(select) the new inserted row in datagrid
Post by: pratikk 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 ???