EasyUI Forum
October 16, 2025, 10:09:57 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 +scrollview:getting a specific row after sort  (Read 9531 times)
korenanzo
Guest
« on: May 10, 2016, 12:00:22 AM »

Hi,

I am using data grid with scrollview, filter and cell editing plugins.

I have a lot of rows, so I set scrollview and  pageSize= 500 : it works well, I can load locally ten thousand  rows  really fast.

I have a specific column as absolute identifier, so I set idField.

when I sort by a column, I'd like to highlight  (select) a specific row: I can't use the "index" param, because it is relative to the current page

so I used this system:

in OnSortColumn event:


Code:
// count the number of pages
var numpages= parseInt(o.datagrid('getData').total / o.datagrid('options').pageSize) +1;

var index= -1;
//loop while I get the desired row
for(var i=0; i<= numpages && index ==-1; i++)
{
o.datagrid('gotoPage',i); 
index= o.datagrid('getRowIndex',myId) ;//if the row is Not in that page,index returns -1
}


problem is that if there is more than 1 page , I get the correct page, nut the index is always 499

Is it a bug or I did something wrong?

Thanks,

RIc
Logged
jarry
Administrator
Hero Member
*****
Posts: 2300


View Profile Email
« Reply #1 on: May 10, 2016, 05:18:37 PM »

You should wait the page to be loaded successfully before calling the 'getRowIndex' method. Be sure to download the corresponding files from http://www.jeasyui.com/extension/datagridview.php and http://www.jeasyui.com/extension/datagrid_filter.php

Code:
    onSortColumn: function(){
        var myId = 202;
        var o = $(this);
        var numpages= parseInt(o.datagrid('getData').total / o.datagrid('options').pageSize) +1;
        gotoPage(1);

        function gotoPage(page){
            if (page<numpages){
                o.datagrid('gotoPage', {
                    page: page,
                    callback: function(){
                        index = o.datagrid('getRowIndex', myId);
                        if (index >= 0){
                            setTimeout(function(){
                                o.datagrid('selectRow', index);
                            },0)
                        } else {
                            gotoPage(page+1);
                        }
                    }
                })
            }
        };
    }
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!