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

[Solved] GridTemplateColumn Header (in edit or insert) Align to the Top instead of the Middle Vertically?

2 Answers 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 16 Oct 2009, 10:35 PM
Hi,

I have a RadGrid with a GridTemplateColumn.  I want my header when I am in Edit or Insert mode, to be aligned to the top vertically?  I searched the forums but found not a single thread on how to do it.  Is everyone else just accepting that the HeaderText is aligned to the middle vertically?  Any help is much aprpeciated.  Thank you.

- Randy

2 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 22 Oct 2009, 10:04 AM
Hello Randy,

My suggestion would be to locate the template column in question (intercepting the PreRender handler of the grid) using the GetColumn(columnName) method from the server API and set its HeaderStyle.VerticalAlign property to Top. This should be done inside a conditional block which checks whether the EditIndexes collection of the grid is not empty (edit mode) or the MasterTableView.IsItemInserted boolean property returns true (insert mode).

If those two conditions are not met, you can revert back that same property to Middle.

Kind regards,
Sebastian
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
Randy
Top achievements
Rank 1
answered on 22 Oct 2009, 05:42 PM
Well your suggestion didn't solve my problem, but I appreciate the effort.  Here is what I finally did that solved my problem:
Keep in mind that MessageBox is the unique name for the TemplateColumn.

        /// <summary>  
        /// This event fires when an item is being created.  
        /// </summary>  
        /// <param name="sender">The object raising the event.</param>  
        /// <param name="e">The event arguments.</param>  
        protected void RGRDMenuItemList_ItemCreated(object sender, GridItemEventArgs e)  
        {  
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
            {  
                GridEditableItem item = e.Item as GridEditableItem;  
 
                if (e.Item.OwnerTableView.IsItemInserted)  
                {  
                    // item is about to be inserted  
                      
                    // Hide the MesageBox field header text.  
                    TableCell messageBoxTableCellheader = (TableCell)item["MessageBox"].Parent.Controls[0];  
                    messageBoxTableCellheader.Text = string.Empty;  
                }  
                else 
                {  
                    // item is about to be edited  
 
                    // Hide the MesageBox field header text.  
                    TableCell messageBoxTableCellheader = (TableCell)item["MessageBox"].Parent.Controls[0];  
                    messageBoxTableCellheader.Text = string.Empty;  
                }  
            }  
        } 

You are probably wondering why i needed to do this, well it's because I am displaying a messageto the user within the EditTemplate.  Hope this helps someone out there.

- Randy
Tags
Grid
Asked by
Randy
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Randy
Top achievements
Rank 1
Share this question
or