4 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 04 Apr 2011, 08:52 AM
Hello Boris,
One approach is to save the HeaderTemplate control ID in the Hidden Field and from the ItemCreatedEvent, and then access the TextBox using the HiddenField value. Here is a sample code.
aspx:
C#:
Client side:
Thanks,
Shinu.
One approach is to save the HeaderTemplate control ID in the Hidden Field and from the ItemCreatedEvent, and then access the TextBox using the HiddenField value. Here is a sample code.
aspx:
<telerik:GridTemplateColumn . . . . . . . . . >
<HeaderTemplate>
<asp:TextBox ID=
"TextBox1"
runat=
"server"
Text=
"Text"
></asp:TextBox>
</HeaderTemplate>
</telerik:GridTemplateColumn>
C#:
protected
void
rad_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridHeaderItem)
{
GridHeaderItem hItem = (GridHeaderItem)e.Item;
TextBox txt1 = (TextBox)hItem.FindControl(
"TextBox1"
);
HiddenField1.Value = txt1.ClientID.ToString();
}
}
Client side:
function
ButtonClick()
// accessing the HeaderTemplate TextBox value from external Button click.
{
var
hidden = document.getElementById(
"HiddenField1"
);
var
txtBox = document.getElementById(hidden.value);
alert(txtBox.value);
}
Thanks,
Shinu.
0
Boris
Top achievements
Rank 1
answered on 04 Apr 2011, 09:01 AM
Hello Shinu,
This is OK but it is not-applicable for me because I build the RadGrid dynamically and I don't know before the count of my template columns.
I would like know - if does exist the client API function that allows to get the header of teh grid and after with the help of findControl (or findElement) to find my needed text box in the header. I do know ID of this text box.
Thank you very much!
Boris
This is OK but it is not-applicable for me because I build the RadGrid dynamically and I don't know before the count of my template columns.
I would like know - if does exist the client API function that allows to get the header of teh grid and after with the help of findControl (or findElement) to find my needed text box in the header. I do know ID of this text box.
Thank you very much!
Boris
0
Hello Boris,
From what I see, Shinu's approach does not require knowing the number of template columns in your grid.
You only need to know the server ID of the TextBox in question. The GridHeaderItem is the whole grid header, not a separate cell from it. As long as the textboxes in the different header templates have different IDs, it should be fine to use this approach.
There is no separate property or method for accessing the grid header. You can access its html element using jQuery but this would not help a lot as you want to then access controls inside it.
Regards,
Tsvetina
the Telerik team
From what I see, Shinu's approach does not require knowing the number of template columns in your grid.
You only need to know the server ID of the TextBox in question. The GridHeaderItem is the whole grid header, not a separate cell from it. As long as the textboxes in the different header templates have different IDs, it should be fine to use this approach.
There is no separate property or method for accessing the grid header. You can access its html element using jQuery but this would not help a lot as you want to then access controls inside it.
Regards,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Boris
Top achievements
Rank 1
answered on 07 Apr 2011, 09:57 AM
Hello Tsvetina,
Thank you very much for the answer.
I have used already this approach!
Thank tou for your attendance!
Boris
Thank you very much for the answer.
I have used already this approach!
Thank tou for your attendance!
Boris