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

Scrollbars appearing when I set GridView column width to fill (*)

7 Answers 719 Views
GridView
This is a migrated thread and some comments may be shown as answers.
newbie
Top achievements
Rank 1
newbie asked on 25 Mar 2011, 06:10 PM
I am using a RadGridView to display information about people.
The last column is for edit/delete buttons.
Whenever I set the last column's width to "*" (to fill the rest of the space), a horizontal scroll bar appears.
If I have 1 column in my grid, then the last column's width properly fills the remaining space and no horizontal scroll bar appears; however, the more columns that I add to the grid, the more you have to scroll to see the edit buttons (the worse the horizontal scroll bar becomes).

This is the markup for my GridView:

<telerik:RadGridView Name="PeopleGrid"
                     Width="{Binding ElementName=theRootElement, Path=ActualWidth}"
                     ItemsSource="{Binding Source={StaticResource people}, Path=People}"
                     IsReadOnly="True"
                     EditTriggers="None">
    <telerik:RadGridView.Columns>
        <telerik:GridViewToggleRowDetailsColumn ExpandMode="Single" />
        <telerik:GridViewDataColumn Header="First Name" DataMemberBinding="{Binding FirstName}" />
        <telerik:GridViewDataColumn Header="Last Name" DataMemberBinding="{Binding LastName}" />
        <telerik:GridViewDataColumn Header="Age" DataMemberBinding="{Binding Age}" />
        <telerik:GridViewDataColumn Header="Marital Status" DataMemberBinding="{Binding MaritalStatus}" />
        <telerik:GridViewDataColumn Width="*">
            <telerik:GridViewDataColumn.CellStyle>
                <Style TargetType="telerik:GridViewCell">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                                    <Button x:Name="btn_EditPerson" ToolTip="Edit">
                                         Edit
                                    </Button>
                                    <Button ToolTip="Delete"
                                            Command="{Binding Source={StaticResource people}, Path=DeletePerson}"
                                            CommandParameter="{Binding .}">
                                              Delete
                                    </Button>
                                </StackPanel>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </telerik:GridViewDataColumn.CellStyle>
        </telerik:GridViewDataColumn>
    </telerik:RadGridView.Columns>
    <telerik:RadGridView.RowDetailsTemplate>
        <DataTemplate>
            <!-- Additional Controls to Display Additional Info...has no affect on problem if I comment this part out -->
        </DataTemplate>
    </telerik:RadGridView.RowDetailsTemplate>
</telerik:RadGridView>


Thanks, in advanced, for your help!




7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 28 Mar 2011, 07:45 AM
Hi,

 Can you remove this setting to see what will be the result? 
Width="{Binding ElementName=theRootElement, Path=ActualWidth}"

Kind regards,
Vlad
the Telerik team
0
Paul
Top achievements
Rank 1
answered on 12 May 2011, 01:59 PM

I am having a similar issues.

The horizontal scrollbar appears if I have any star width columns, regardless of whether it is actually required.

I have tried having both single and multiple "*" columns and changing which column is starred and it happens the same.

I does not seem to be anything to do with the visual container as it occurred when I had a fixed sized Grid containing the GridView and when I had a star sized Grid. 

Neither does fixing the width of the GridView rather than having it fill the containing Grid solve the issue.

The strange thing is that it disappears if you resize the containing visual container at runtime (either to make it larger or smaller), but it does then reappear if you reduce the size of the GridView itself (still regardless of if the scrollbar is actually required).

0
Vlad
Telerik team
answered on 18 May 2011, 07:11 AM
Hi,

 Can you post more info about the grid version at your end? I've checked your account however you do not have any downloads. 

Greetings,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Paul
Top achievements
Rank 1
answered on 18 May 2011, 10:44 AM
Sorry, I forgot to give the version. I'm using the Q1 2011 Sp1 release for .NET 4 (assembly version number 2011.1.419.40)
0
Vlad
Telerik team
answered on 18 May 2011, 01:48 PM
Hi,

 I've tried to replicate this in various grid setups however everything worked as expected on my end. You can check the attached application for reference. 

Regards,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Paul
Top achievements
Rank 1
answered on 18 May 2011, 04:26 PM

Thank you very much for the sample project, I think it has helped me to narrow down the issue.

If I start from your sample project and bind the GridView to an empty collection then I get the scrollbars doing interesting things. As soon as you populate the collection then it works perfectly.

0
newbie
Top achievements
Rank 1
answered on 29 Sep 2011, 09:36 PM
The reason I had Width="{Binding ElementName=theRootElement, Path=ActualWidth}" was because of the * problem.
Anyways, it turns out that it isn't a Telerik specific problem.
I found out that scrollbars will appear in a GridView if you mix * with values.
I changed all of the widths to some multiple of * and it fixed the problem.
Tags
GridView
Asked by
newbie
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Paul
Top achievements
Rank 1
newbie
Top achievements
Rank 1
Share this question
or