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

JavaScript "$find" for object in "ItemTemplate"

2 Answers 172 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tomasz
Top achievements
Rank 1
Tomasz asked on 05 May 2011, 03:53 PM
Hello,

I need to write js function for custom validation of the ComboBox. Unfortunately this ComboBox is defined within ItemTemplate. So my
js code fails with message like " object not found in this context " :
.....

var

 

cbxDate = $find("<%= ComboBox.ClientID %>");
......
. How can I solve this issue?

Regards
Tomasz

 

2 Answers, 1 is accepted

Sort by
0
Badri
Top achievements
Rank 1
answered on 06 May 2011, 03:20 AM
Hi Tomsaz,

You can try finding the rendered id by capturing it from the F12.
You can try this

 $find("<%# ComboBox.ClientID %>");

$get("<%# ComboBox.ClientID %>")._element.

Thanks.
Badri


0
Shinu
Top achievements
Rank 2
answered on 09 May 2011, 06:22 AM
Hello Badri,

I am not quite sure about the scenario. I suppose you want to access the RadComboBox which is side the ItemTemplate of the RadGrid.
If that is the case you can access the control using the findControl() method. Here is a sample code for accessing the control in RowClick event.
aspx:
<telerik:GridTemplateColumn HeaderText="total">
      <ItemTemplate>
        <telerik:RadComboBox ID="Combo1" runat="server"></telerik:RadComboBox>
      </ItemTemplate>
</telerik:GridTemplateColumn>
. . . . . . . . . . . . . . .
<ClientSettings ClientEvents-OnRowClick="onRowClick">
</ClientSettings>

Javascript:
function onRowClick(sender, args)
  {
       var combo = args.get_gridDataItem().findControl("Combo1");
  }

Thanks,
Shinu.
Tags
General Discussions
Asked by
Tomasz
Top achievements
Rank 1
Answers by
Badri
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or