This is a migrated thread and some comments may be shown as answers.

[Solved] Scroll to a specific row in the Grid

3 Answers 178 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Scott
Top achievements
Rank 1
Scott asked on 29 Dec 2010, 10:05 PM

In my app most screens have a list of objects in a grid and the concept of a currently selected object.  I need to be able to force the currently selected object (row in the grid) to be visible in the grid when a user goes back to a page.  Right now if the user selects an item that is far down the list when they come back to the page they have to scroll to the item again to see that it is still selected.  Is there any way to do this? Here is a little piece of java script I use to change the look of the currently selected row in the grid.  I was hoping to be able to insert something in here like: row.scrollTo or something.

function onAccountListLoaded() {
                // highlight the account in the list that is the currently selected account
                <%if(Session["CurrentAccount"]!=null){ %>
                var grid = $('#AccountList').data('tGrid');
                var index=0;
                while((row = grid.$rows()[index++])!=null)
                {
                    if(row.cells[0].innerHTML==<%=((MDIT.Accounting.Library.Data.Account)Session["CurrentAccount"]).Id %>)
                        row.className = 't-state-error';
                }
                <%} %>
            }

3 Answers, 1 is accepted

Sort by
0
Scott
Top achievements
Rank 1
answered on 21 Feb 2011, 06:27 PM
hmm two months and no reply, is there really no way to accomplish this?
0
Scott
Top achievements
Rank 1
answered on 21 Feb 2011, 06:42 PM
figured it out:

            function 
onOfficeListLoaded() 
{<BR>                
// highlight the office in the list that is the currently selected 
cycle<BR>                
<%if(Session["CurrentCycleOffice"]!=null){ 
%><BR>                
var grid = 
$('#OfficeList').data('tGrid');<BR>                
if(grid==null) 
return;<BR>                
var 
index=0;<BR>                
var scrollTo = 
0;<BR>                
while((row = 
grid.$rows()[index++])!=null)<BR>                
{<BR>                    
if(row.cells[0].innerHTML==<%=((Bill_Pay.Models.CycleOfficeModel)Session["CurrentCycleOffice"]).office.Id 
%>)<BR>                    
{<BR>                        
row.className = 
't-state-selected';<BR>                        
break;<BR>                    
}<BR>                    
scrollTo += 
row.offsetHeight;<BR>                
}<BR>                
$('#OfficeList 
.t-grid-content').scrollTop(scrollTo);<BR>                
<%} 
%><BR>            
}<BR>
0
Deepak
Top achievements
Rank 1
answered on 16 Nov 2012, 07:56 PM
Thanks!
Tags
Grid
Asked by
Scott
Top achievements
Rank 1
Answers by
Scott
Top achievements
Rank 1
Deepak
Top achievements
Rank 1
Share this question
or