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

[Solved] Horizontal scrolling

6 Answers 118 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sajjad Shah
Top achievements
Rank 1
Sajjad Shah asked on 23 Dec 2010, 07:03 PM
How do I programtically scroll the scroll bar to the right in the grid...?

6 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 24 Dec 2010, 03:49 PM
Hi Sajjad Shah,

You may use the ScrollIntoView method of RadGridView, passing the last column as a second parameter) .

Kind regards,
Pavel Pavlov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Sajjad Shah
Top achievements
Rank 1
answered on 29 Dec 2010, 03:14 PM
I have tried this:

this

 

 

.RadGridView1.ScrollIntoView(this.RadGridView1.SelectedItem, this.RadGridView1.Columns[this.RadGridView1.Columns.Count - 1]);

 

 

and I get a targetparameter count exception. My requirement is to scroll the horizontal scroll bar to the extreme right beause therer are scenarios when the columns are more than what can be fit in a screen also number of columns dynamically change during what user has selected..

Thanks.
0
Maya
Telerik team
answered on 30 Dec 2010, 10:02 AM
Hi Sajjad Shah,

I am sending you a sample project demonstrating the proposed solution.  Please take a look at it and let us know in case of any discrepancies according to your requirements.

Regards,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Sajjad Shah
Top achievements
Rank 1
answered on 30 Dec 2010, 03:41 PM
OK. I do not get the error message anymore (that was the column count problem as I had few hidden columns)

Now, My scenario is more like this (change your code in mainPage.xaml in your sample to below):

<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" IsVisible="False" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Number}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Position}"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Country}" IsVisible="False" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Number}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Position}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Country}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Number}" IsVisible="False" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Position}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Country}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Number}" IsVisible="False" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Position}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Country}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Number}"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Position}" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Country}" IsVisible="False" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" IsVisible="False" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Number}" IsVisible="False" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Position}"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Country}" IsVisible="False" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>


After hiding few columns. When I click the scroll to the right button. it does not do anything. Although it does appear that scrollbar should scroll to the right..
0
Maya
Telerik team
answered on 03 Jan 2011, 08:54 AM
Hi Sajjad Shah,

This is the expected behavior as you are trying to scroll to an element that is not visible. Still, the fact that the column's property IsVisible is set to "False" does not mean this column is not a part of the Columns collection. What you can do is to check if the column is visible before scrolling to it. For example:

private void Button1_Click(object sender, RoutedEventArgs e)
        {
            for (int i = this.playersGrid.Columns.Count - 1; i >= 1; i--)
            {
                if(this.playersGrid.Columns[i].IsVisible)
                {
                    this.playersGrid.ScrollIntoView(this.playersGrid.SelectedItem, this.playersGrid.Columns[i]);
                    return;
                }              
            }          
        }
 

All the best,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Sajjad Shah
Top achievements
Rank 1
answered on 03 Jan 2011, 06:09 PM
Thanks. That did the trick.
Tags
GridView
Asked by
Sajjad Shah
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Sajjad Shah
Top achievements
Rank 1
Maya
Telerik team
Share this question
or