RadGridView add an extra column at the end

17 posts, 0 answers
  1. Chris Thierry
    Chris Thierry avatar
    138 posts
    Member since:
    Jun 2010

    Posted 13 Sep 2010 Link to this post

    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.
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 13 Sep 2010 Link to this post

    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
  3. DevCraft banner
  4. Chris Thierry
    Chris Thierry avatar
    138 posts
    Member since:
    Jun 2010

    Posted 13 Sep 2010 Link to this post

    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.
  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 13 Sep 2010 Link to this post

    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
  6. Saravana Kumar
    Saravana Kumar avatar
    21 posts
    Member since:
    Jul 2006

    Posted 04 Oct 2010 Link to this post

    I got the same issues, both the suggested options ColumnWidth="*" or Width="*" (or column level) didn't work.
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 04 Oct 2010 Link to this post

    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
  8. Saravana Kumar
    Saravana Kumar avatar
    21 posts
    Member since:
    Jul 2006

    Posted 04 Oct 2010 Link to this post

    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?
  9. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 05 Oct 2010 Link to this post

    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
  10. Saravana Kumar
    Saravana Kumar avatar
    21 posts
    Member since:
    Jul 2006

    Posted 05 Oct 2010 Link to this post

    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?
  11. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 05 Oct 2010 Link to this post

    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
  12. Saravana Kumar
    Saravana Kumar avatar
    21 posts
    Member since:
    Jul 2006

    Posted 06 Oct 2010 Link to this post

    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
  13. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 07 Oct 2010 Link to this post

    <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
  14. Saravana Kumar
    Saravana Kumar avatar
    21 posts
    Member since:
    Jul 2006

    Posted 08 Oct 2010 Link to this post

    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 
  15. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 08 Oct 2010 Link to this post

    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
  16. somasundaram kumarasamy
    somasundaram kumarasamy avatar
    1 posts
    Member since:
    Oct 2009

    Posted 12 Nov 2010 Link to this post

    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
  17. yjh
    yjh avatar
    67 posts
    Member since:
    Aug 2007

    Posted 30 Jul 2011 Link to this post

    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.
  18. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 04 Aug 2011 Link to this post

    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 >>

Back to Top
DevCraft banner