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

RadGrid GridTemplateColumn Alignment

1 Answer 403 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mahesh Babu
Top achievements
Rank 1
Mahesh Babu asked on 11 Aug 2009, 02:18 PM
Hi,

I have a radGrid to which I want to add GridTemplateColumns which can be of type text,currency and controls. I want to align these something like text to be left aligned, currency to be right aligned with some format and controls to center aligned.

Is there a way to do this???

Thanks,
Mahesh

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Aug 2009, 11:03 AM
Hi Mahesh Babu,

I guess, you have seperate GridtemplateColumns with seperate format of TemplateItem, if so one sugestion would be setting UniqueName for each column and set the ItemStyle-HorizontalAlign property of gridcolumn accordingly after checking the UniqueName of column in PreRender event of RadGrid.

C#:
 
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    foreach (GridColumn col in RadGrid1.MasterTableView.Columns) 
    { 
        if (col.UniqueName == "TemplateColumn1"
        { 
           RadGrid1.MasterTableView.GetColumn("TemplateColumn1").ItemStyle.HorizontalAlign = HorizontalAlign.Right; 
        } 
        if (col.UniqueName == "TemplateColumn2"
        { 
            RadGrid1.MasterTableView.GetColumn("TemplateColumn1").ItemStyle.HorizontalAlign = HorizontalAlign.Center; 
        } 
    } 

If you have all the text, currency value and any controls in same GridTemplateColumn, then better way is to align the contents from ASPX itself.

-Shinu.
Tags
Grid
Asked by
Mahesh Babu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or