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

dynamic header text at runtime

3 Answers 228 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 03 Oct 2011, 12:11 PM

i am working on a web application that needs to load customised grid column headers depending on the logged in users locale.

there are a number of different grids in the application, and whilst many of the header labels for these grids are generic, a small number are not and need to be loaded at runtime to the term relevant to them.

how would i do this?

currently my grid is populated from a datatable and the column names are coming from the datatable column names.

i think first step will be to create my localised column names in a database for each locale and bring them into my datatable.

i just need to know how to populate/override my radgrid column header text with the database values for specific columns.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Oct 2011, 12:18 PM
Hello Mark,

In Page_PreRender, you can access specified column using RadGrid1.MasterTableView.GetColumn method, and set the desired text in HeaderText and Rebind() the grid.
C#:
protected void Page_PreRender(object o, EventArgs e)
{
    GridHeaderItem headerItem = RadGrid1.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;
    headerItem["ColUniqueName"].Text = "MODIFIED";
}

Thanks,
Shinu.
0
Mark
Top achievements
Rank 1
answered on 03 Oct 2011, 12:38 PM
ok shinu

so this would replace the code that currently sets headertext or override it?

the values are set in the fill grid as

For Each col As DataColumn In _vyData.Columns

                gc = New GridBoundColumn
                Me.uxVineyard.Columns.Add(gc)
                gc.HeaderText = col.ColumnName
                gc.UniqueName = col.ColumnName
                gc.DataField = col.ColumnName
                gc.Display = True
                gc.HeaderStyle.Width = Unit.Pixel(170)
                gc.ItemStyle.Wrap = True
            Next

 

 

 


0
Mark
Top achievements
Rank 1
answered on 03 Oct 2011, 01:48 PM
Adding the header text override at page_prerender now stops any row editing or paging from working as it did before.

how do i overcome this?
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mark
Top achievements
Rank 1
Share this question
or