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

Command column misses header

3 Answers 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dmitry
Top achievements
Rank 1
Dmitry asked on 23 Sep 2011, 01:02 PM
Hello,
I create all columns programmatically and try to add a command column. This is how I do that:
Columns.Clear();
            Columns.Add(new GridEditCommandColumn
                            {
                                ItemStyle =
                                    {
                                        Width = Unit.Pixel(50)
                                    },
                                ButtonType = GridButtonColumnType.ImageButton,
                            });
            foreach (GridColumn column in _columnBuilder.BuildColumns(_zsheet, _zTable, _dataSourceProvider))
            {
                Columns.Add(column);
            }
Column added successfully but I can't see its header. 1st data column header is placed over command column. Do I have to do something else when adding a command column?
Thank you.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Sep 2011, 02:17 PM
Hello Dmitry,

I am not quite sure about the event from which you are creating the columns.
When generating a grid in the Page_Init event handler, grid columns should be added to the Columns collection of the MasterTableView after their attributes are set. No ViewState is required for grid structure to be persisted as it is recreated on each page initialization:

When creating RadGrid on Page_Load event, the columns or detail tables should be added to the corresponding collection first and then values for the properties of this instance should be set. Remember to check the condition (Not IsPostBack) to avoid adding the same structure objects to the grid twice. This is important because no ViewState is managed for the object before it has been added to the corresponding collection.
Also take a look into the following help article for more on this.
Programmatic Creation.

Thanks,
Shinu.
0
Dmitry
Top achievements
Rank 1
answered on 26 Sep 2011, 03:28 PM
Hello,
Fortunately I have already passed stage when column had not created programmatically :)
I create grid from Page_Init and it seems to work fine now. Everything I do is try to add a command column before creating data columns. Just a single line of code with a single column, and it's not set up correctly.
0
Dmitry
Top achievements
Rank 1
answered on 28 Sep 2011, 01:51 PM
I solved the issue. Everything I had to do was assign Width in column ItemStyle, HeaderStyle and FooterStyle.
Tags
Grid
Asked by
Dmitry
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Dmitry
Top achievements
Rank 1
Share this question
or