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

Extra colomn

9 Answers 128 Views
GridView
This is a migrated thread and some comments may be shown as answers.
kristjan einarsson
Top achievements
Rank 1
kristjan einarsson asked on 24 Nov 2009, 10:16 AM
Hi,
I am having some problems with the datagrid and extra empty columns, see attachments.

I'm creating the datagrid in codebehind, via
datagrid.ItemsSource = gridDataSet.Tables[0].DefaultView; 

And there is an extra empty column that appears, is there any way to make it disappear ?

best regards
krissi.

9 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 24 Nov 2009, 11:08 AM
Hi krissi,

Actually this is not extra column - grid rows are just stretched to the available grid width.

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
kristjan einarsson
Top achievements
Rank 1
answered on 24 Nov 2009, 11:33 AM
Hi again,
I am sorry, but I am not with you on this one, [quote] grid rows are just stretched to the available grid width. [/quote]

As I see it the columns are just stretched to take up the space they need and the grid add this filler column, well I would
like to get rid of this extra filler if possible.

Is there something I can to to remedy this ?

For further clarification I uploaded a new pick with a red square around the filler column.

Thanks for the quick answer.

Best regards
krissi.
0
Milan
Telerik team
answered on 24 Nov 2009, 01:36 PM
Hello kristjan einarsson,

Currently this is the expected behavior of RadGridView. For the time being the only wayto workaround the problem is to setup the columns in such a way that they fill all of the available space.

Is this behavior a show-stopper for you?


Greetings,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
kristjan einarsson
Top achievements
Rank 1
answered on 24 Nov 2009, 01:59 PM
Hi again,
Yes it is a showstopper, since the data is dynamic, I never have a clue how may columns there are going to be.
But I must be able to create the columns at run time and set the last column with the remaining width.

Best regards
krissi.
0
Vlad
Telerik team
answered on 24 Nov 2009, 02:22 PM
Hello krissi,

You can check the standard MS DataGrid for more info - our grid is rendered in exactly the same way. This is not an extra column - the grid rows are measured with the grid width. No extra cells or columns!

Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Alexander
Top achievements
Rank 1
answered on 24 Nov 2009, 04:25 PM

Hello,

I've got the same requirements as Kristjan. It would be great, if the last column could by default be sized to use the remaining available horizontal space. 

Alex

0
kristjan einarsson
Top achievements
Rank 1
answered on 25 Nov 2009, 03:29 PM
Hi,
found a solution for the problem.
just set the AutoGeneratingColumn event
 
private void datagrid_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e) 
       e.Column.Width = new GridViewLength(20, GridViewLengthUnitType.Star); 


Works for my needs.

Best regards
Krissi.
0
ofer alper
Top achievements
Rank 1
answered on 20 Jan 2010, 07:57 PM
I tried to set up the columns to fit the grid width by giving the last column width = grid.width - total width of the rest of the columns.

This worked, but still if the user resizes the columns i get the "extra" column again. 

How can i avoid it? 

Thanks,

Ofer
0
Vlad
Telerik team
answered on 21 Jan 2010, 07:02 AM
Hi,

You can set "*" Width for the last column:

RadGridView1.Columns[RadGridView1.Columns.Count - 1].Width = new Telerik.Windows.Controls.GridViewLength(1, Telerik.Windows.Controls.GridViewLengthUnitType.Star);


Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
kristjan einarsson
Top achievements
Rank 1
Answers by
Vlad
Telerik team
kristjan einarsson
Top achievements
Rank 1
Milan
Telerik team
Alexander
Top achievements
Rank 1
ofer alper
Top achievements
Rank 1
Share this question
or