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

RadGridView add an extra column at the end

16 Answers 383 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris Thierry
Top achievements
Rank 1
Chris Thierry asked on 13 Sep 2010, 03:40 PM
Hi, I have a radgridview that is showing 3 columns, I don´t know why but Telerik adds one extra column at the end without a column name, I don´t want to show it, anybody knows how to deal with this issue?. This always happens....
Thank you.

16 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 13 Sep 2010, 03:51 PM
Hello Chris Thierry,

You need to set either the ColumnWidth property of the GridView to "*" or the Width property of any of the columns to "*".

Hope this helps.

Sincerely yours,
Veselin Vasilev
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
Chris Thierry
Top achievements
Rank 1
answered on 13 Sep 2010, 04:04 PM
Hi,
are you talking about gridview or radgridview?, I'm talking about radgridview, I found something related to property AutoGeneratingColumn, Am I correct?
Thank you.
0
Veselin Vasilev
Telerik team
answered on 13 Sep 2010, 04:18 PM
Hi Chris Thierry,

I meant RadGridView. Here is a sample:

<telerik:RadGridView ColumnWidth="*" Name="clubsGrid" />   


Kind regards,
Veselin Vasilev
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
Saravana Kumar
Top achievements
Rank 1
answered on 04 Oct 2010, 06:38 AM
I got the same issues, both the suggested options ColumnWidth="*" or Width="*" (or column level) didn't work.
0
Vlad
Telerik team
answered on 04 Oct 2010, 07:38 AM
Hi,

 Can you post a screenshot from the your grid and the grid XAML to see how you've applied this suggestion?

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
Saravana Kumar
Top achievements
Rank 1
answered on 04 Oct 2010, 05:25 PM
Hi Vlad,

I did some analysis and figured out the problem is mainly due to the usage of ScrollViewer as parent to RadGridView.

<ScrollViewer  VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
            <StackPanel>
                <telerikGrid:RadGridView x:Name="radGridView" Margin="8"
                                 ColumnWidth="*"
                                 AutoGenerateColumns="False"
                                 ItemsSource="{Binding Source={StaticResource DataSource}, Path=Cars}">
                    <telerikGrid:RadGridView.Columns>
                        <telerikGrid:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" />
                        <telerikGrid:GridViewDataColumn Header="Description" DataMemberBinding="{Binding Description}" />
                    </telerikGrid:RadGridView.Columns>
                </telerikGrid:RadGridView>
            </StackPanel>
        </ScrollViewer>

In my real scenario ScrollViewer/StackPanel is required, since there are other controls inside the StackPanel. In this case as soon as I put ColumnWidth="*" property on RadGridView, the width of each column and RadGridView itself extends by many magnitude. Is there any other solution to this issue?
0
Vlad
Telerik team
answered on 05 Oct 2010, 07:08 AM
Hello,

 Controls like ScrollViewer and StackPanel will measure their child controls with infinity height and width. If you set width for the grid explicitly ColumnWidth setting will work as excepted. 

Best wishes,
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
Saravana Kumar
Top achievements
Rank 1
answered on 05 Oct 2010, 11:20 AM
Hi Vlad,

We can't put a fixed width for RadGridView, based on the design the grid get stretched depending on available space. Is there any other way we can avoid this extra column. or can we put a request for next version of the RadGridView?
0
Pavel Pavlov
Telerik team
answered on 05 Oct 2010, 02:55 PM
Hello Saravana Kumar,

Please have a look at the attached sample, and let me know in case it  does not cover your needs.

Greetings,
Pavel Pavlov
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
Saravana Kumar
Top achievements
Rank 1
answered on 06 Oct 2010, 05:41 PM
Hi Pavel,

I slightly modified your solution to highlight the issue

<Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="2"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
  
        <TextBlock Grid.Column="0" FontSize="20" Text="Left Hand Side"/>
        <my:GridSplitter Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Center" Background="Black" Width="5"/>
        <ScrollViewer Grid.Column="2" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
            <StackPanel >
                <TextBlock  FontSize="20" Text="Right hand side"/>
                <telerikGrid:RadGridView x:Name="radGridView" Margin="8"
                                 AutoGenerateColumns="False" ColumnWidth="*">
                    <telerikGrid:RadGridView.Columns>
                        <telerikGrid:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" />
                        <telerikGrid:GridViewDataColumn Header="Description" DataMemberBinding="{Binding Description}"/>
                    </telerikGrid:RadGridView.Columns>
                </telerikGrid:RadGridView>
            </StackPanel>
        </ScrollViewer>
    </Grid>

If you place the above code on your mainpage.xaml and execute it. You'll notice the RHS width is indefinite and there is a big horizondal scroll bar, the width of the RadGrid also expands to fit the scrollviewer width.

If you simple remove the
VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"

properties from the ScrollViewer, then the RadGrid works as expected (without additional column at the end, and without a lengthy horizondal scrollbar), but you'll notice the Vertical scroll visible, even though its not required. Any idea why this is happening and possible remedies?

Hope you can replicate the issue.

Regards,
Saravana
0
Pavel Pavlov
Telerik team
answered on 07 Oct 2010, 03:29 PM
<Grid x:Name="LayoutRoot">
      <Grid.ColumnDefinitions>
          <ColumnDefinition/>
          <ColumnDefinition Width="2"/>
          <ColumnDefinition/>
      </Grid.ColumnDefinitions>
      <TextBlock Grid.Column="0" FontSize="20" Text="Left Hand Side"/>
      <ScrollViewer Grid.Column="2" VerticalScrollBarVisibility="Auto" >
          <StackPanel >
              <TextBlock  FontSize="20" Text="Right hand side"/>
              <telerikGrid:RadGridView x:Name="radGridView" Margin="8" Height="Auto"
                               AutoGenerateColumns="False" ColumnWidth="*">
                  <telerikGrid:RadGridView.Columns>
                      <telerikGrid:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" />
                      <telerikGrid:GridViewDataColumn Header="Description" DataMemberBinding="{Binding Description}"/>
                  </telerikGrid:RadGridView.Columns>
              </telerikGrid:RadGridView>
          </StackPanel>
      </ScrollViewer>
  </Grid>
Hello Saravana Kumar,

I found the above code to work as expected . Please note that I have removed the HorizontalScrollBarVisibility="Auto" but left the setting for the vertical scrollbar.

As a result - no additional scrollbars are displayed and RadGridView is displayed correctly .



Best wishes,
Pavel Pavlov
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
Saravana Kumar
Top achievements
Rank 1
answered on 08 Oct 2010, 06:00 AM
Hi Pavel,

Thanks for taking your time, I realized as soon as I posted my previous reply, if I remove the HorizontalScrollBarVisibility="Auto" it works expected.

But there is problem, the horizontal scroll bar is never displayed. Also, this is not an ideal fix, we use RadGridView at around 20 places and they all got the same problem. In some cases the scrollviewer container got variety of things like panels and grids inside the panels etc.  Everything is fine with RadGridView it resized nicely with the parent container, except this additional column at the end consuming unnecessary space.

Even in cases where I specify the column width for each column (autogenerated = false), I'm experincing the same behavior. 

Can I raise it as a defect or its by design?

Regards,
Saravana 
0
Pavel Pavlov
Telerik team
answered on 08 Oct 2010, 12:04 PM
Hello Saravana Kumar,

The behavior described is by design .
When all the columns in RadGridView have width less than  the width of the viewport , the rest of the space is filled with what you call "additional column" .

To avoid this, you may set the columns to fill the available space.
At least one of the columns should have star-size width . This way columns should fill the available space.


Best wishes,
Pavel Pavlov
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
somasundaram kumarasamy
Top achievements
Rank 1
answered on 12 Nov 2010, 10:58 AM
Hi,

I fixed this issue by setting Radgridview.width=Layoutroot.ActualWidth in RadGridView_DataLoaded event. By setting the parentcontrol(may be grid) actual width to RadGridview width in runtime, Radgridview indefinite width came in control. I haven't also removed this line :
VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto".
Everything is working for me like scrollbars, removed extra space column. Hope this will be helpful to you.

Regards
Soma
0
yjh
Top achievements
Rank 1
answered on 30 Jul 2011, 10:09 AM
I have a radgridview, which has 4 columns. Column 1-3 set width to 0.3* 0,3* 0.4*,the rightmost column 4's width set to 55 pixl.

But the extra empty column still exist,and column header seperation line lost.

Two attach files are same, I can't delete one of them.
0
Maya
Telerik team
answered on 04 Aug 2011, 03:53 PM
Hello Yjh,

This behavior is expected when defining the columns' width in such manner. Basically, the idea behind setting a length property to a proportional star value (3*, 0.5*, 10*) is that it takes this part (3, 0.5, 10) of the whole remaining space. So, if you have a column set to 0.3*, but the space left is a bit bigger and cannot be divided exactly by this value, you will get the behavior you experience. The whole space will be filled when you have a column set as "*" or setting the ColumnWidth property of the grid.
As for the problem with column headers's lines, it is known and we currently work on resolving it.

 
All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
GridView
Asked by
Chris Thierry
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Chris Thierry
Top achievements
Rank 1
Saravana Kumar
Top achievements
Rank 1
Vlad
Telerik team
Pavel Pavlov
Telerik team
somasundaram kumarasamy
Top achievements
Rank 1
yjh
Top achievements
Rank 1
Maya
Telerik team
Share this question
or