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

synchronize scrollbars of 2 RadGrid

2 Answers 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 18 Mar 2009, 11:20 AM
In my application I have 2 RadGrids, both have the same width.

Now I need to synchronize the scrollbars in a mirror way, that means if I move the scrollbar of the second RadGrid to the right, the Scrollbar of the first RadGrid shall move to the left.

Here is my code which doesn't work exactly (there is a differenz of 40px):

function Scroll2(sender, eventArgs)  
 {  
 
     var RadGrid1 = $find("<%= RadGrid1_ClientID %>");  
     if(RadGrid1 != null)   
     {  
     var scrollArea = RadGrid1.GridDataDiv;  
     scrollArea.scrollTop = eventArgs.get_scrollTop();  
     scrollAreascrollArea.scrollLeft = scrollArea.offsetWidth-eventArgs.get_scrollLeft();  
     }  
     
 } 

Does someone see the fault?

thanks

Christian

2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 23 Mar 2009, 06:00 PM
Hello Christian,

To attain the functionality you are searching for, you need to subtract the width of the visible div (GridDataDiv) from the offsetWidth property of the MasterTableView. Afterward you just remove the value of the eventArgs.get_scrollLeft().

To clarify please review the following code snippet:

            function OnScroll2(sender, eventArgs) { 
                var RadGrid1 = $find("<%= RadGrid1.ClientID %>"); 
                 
                if (RadGrid1 != null) { 
                    var scrollArea = RadGrid1.GridDataDiv; 
                    var masterTableDiv = RadGrid1.get_masterTableView().get_element(); 
                     
                    var realDivWidth = masterTableDiv.offsetWidth - scrollArea.offsetWidth; 
                    scrollArea.scrollTop = eventArgs.get_scrollTop(); 
                    scrollArea.scrollLeft = realDivWidth - eventArgs.get_scrollLeft(); 
                } 
            } 

All the best,
Georgi Krustev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Christian
Top achievements
Rank 1
answered on 24 Mar 2009, 03:19 PM
great thanks
Tags
Grid
Asked by
Christian
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Christian
Top achievements
Rank 1
Share this question
or