Change RadGrid column header text on client

7 posts, 0 answers
  1. Ted
    Ted avatar
    5 posts
    Member since:
    Apr 2012

    Posted 17 Oct 2012 Link to this post

    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?

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Oct 2012 Link to this post

    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.

  3. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts
    Member since:
    Sep 2012

    Posted 18 Oct 2012 Link to this post

    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.

  4. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 02 Jul 2013 Link to this post

    But what to do with export? I need the same changed name (not an original one!) was in the exported PDF/Excel file!

  5. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts
    Member since:
    Sep 2012

    Posted 05 Jul 2013 Link to this post

    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.

  6. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 16 Jul 2013 Link to this post

    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...

  7. Daniel
    Admin
    Daniel avatar
    4788 posts
    Member since:
    Dec 2014

    Posted 19 Jul 2013 Link to this post

    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.

Back to Top