
Iker Llanos
Top achievements
Rank 1
Iker Llanos
asked on 10 Aug 2011, 08:34 AM
I want to change a column header text in client-side (javascript + jquery). The column header support reorder.
I have this code:
I get the header text to be changed but I lose the link to reorder the column. Is there any other way to get the header text changed?
Thanks
I have this code:
$(grid.get_masterTableView().getColumnByUniqueName('ColumnUniqueName').get_element()).text('New header text')
I get the header text to be changed but I lose the link to reorder the column. Is there any other way to get the header text changed?
Thanks
4 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 10 Aug 2011, 08:55 AM
Hello Iker,
I also faced the same issue when changing header text from client side. In order to persist sorting when changing header text, attach ItemDataBound event and set header text programmatically.
C#:
Thanks,
Princy.
I also faced the same issue when changing header text from client side. In order to persist sorting when changing header text, attach ItemDataBound event and set header text programmatically.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridHeaderItem)
{
GridHeaderItem header = (GridHeaderItem)e.Item;
((LinkButton)header[
"ColumnUniqueName"
].Controls[0]).Text =
"Your Text"
;
}
}
Thanks,
Princy.
0

Iker Llanos
Top achievements
Rank 1
answered on 10 Aug 2011, 09:06 AM
I need to be done in client-side. Can it be done or it is impossible?
Thanks
Thanks
0
Hello Iker Llanos,
You will have to set the text of the anchor element rendered in the header cell instead of the header cell text:
I hope this helps.
Regards,
Martin
the Telerik team
You will have to set the text of the anchor element rendered in the header cell instead of the header cell text:
$telerik.$(
grid
.get_masterTableView().getColumnByUniqueName(
'ColumnUniqueName
'
).get_element().getElementsByTagName(
'a'
)).text(
'New header text'
);
I hope this helps.
Regards,
Martin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

Dariusz
Top achievements
Rank 1
answered on 10 Nov 2011, 08:51 AM
Hi Princy..
Your code works great but I had problems with it when I tried changing the name of the GridTemplateColumn...
I got an error
Any idea how can i solve it?
ok, solved it already..
I didn't have sorting enabled for that column so instead of LinkButton I had to use LiteralControl for that case.
Your code works great but I had problems with it when I tried changing the name of the GridTemplateColumn...
I got an error
Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.LinkButton'
Any idea how can i solve it?
ok, solved it already..
I didn't have sorting enabled for that column so instead of LinkButton I had to use LiteralControl for that case.