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

Change RadGrid column header text on client

6 Answers 476 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ted
Top achievements
Rank 1
Iron
Iron
Ted asked on 17 Oct 2012, 05:32 PM
How can I set/change the text of a column header on the client in response to a client-side event?  I would expect a GridTableView.set_columnHeaderText() or GridColumn.set_headerText(), but I don't see any methods like this?

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Oct 2012, 04:18 AM
Hi,

Try the following javascript to set header text from client side.
JS:
function OnColumnCreated(sender, args)
{
    var column = args.get_column();
    switch (column.get_uniqueName())
    {
        case "EmployeeID":
            column.get_element().innerHTML = "your text"; //setting new HeaderText
            break;
    }
}

Thanks,
Shinu.
0
Tsvetoslav
Telerik team
answered on 19 Oct 2012, 04:26 AM
Hello Ted,

If you need to do this outside of any RadGrid's event just go the way shinu has pointed and get a reference to the column's dom element as follows: $find("<%= RadGrid1.ClientID %>).get_masterTableView().getColumnByUniqueName("your column's uniquename goes here").get_element().

Hope it helps.


Regards,
Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Alexander
Top achievements
Rank 1
answered on 02 Jul 2013, 03:01 PM
But what to do with export? I need the same changed name (not an original one!) was in the exported PDF/Excel file!
0
Tsvetoslav
Telerik team
answered on 05 Jul 2013, 12:26 PM
Hi Alexander,

Here is the solution:
http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-excel-export-column-header-always-centered.aspx
 
Regards,
Tsvetoslav
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Alexander
Top achievements
Rank 1
answered on 16 Jul 2013, 08:45 AM
Hi,
you mean
e.ExportOutput
contains the actual markup, with changes made by javascript?

But by this moment, I already changed my code to "postback" the page and change the header's title on server-side...
0
Daniel
Telerik team
answered on 19 Jul 2013, 08:32 AM
Hello Alexander,

The e.ExportOutput contains all the data which will be saved to the file. This means that if something is not there, it won't be exported.

Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Ted
Top achievements
Rank 1
Iron
Iron
Answers by
Shinu
Top achievements
Rank 2
Tsvetoslav
Telerik team
Alexander
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or