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

Find objects ClientSide in RadPanelItem

1 Answer 119 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
jgig
Top achievements
Rank 1
jgig asked on 03 Oct 2008, 04:52 PM
I am trying to (via javascript) find a Button inside of a RadPanelItem. I read how to do it but all the samples I read always find Telerik controls. When I tried doing it the same way for the button the button obj in javascript is null. I am able to find the colorpicker in the sample below, but not the button.

RadPanelItem

<

telerik:RadPanelBar ID="RadPanelBar1" runat="server">
  <Items>
    <telerik:RadPanelItem Text="Travelers" Value="Travelers" Expanded="true">
     <Items>
      <telerik:RadPanelItem>
       <ItemTemplate>
          <asp:Button ID="ColorPicker" OnClientClick="GetbtnTEST();" runat="server" Text="TEST"/>
         <telerik:RadColorPicker ID="sdColorPicker" runat="server"></telerik:RadColorPicker>
       </ItemTemplate>
      </telerik:RadPanelItem>
     </Items>
    </telerik:RadPanelItem>
  </Items>
</
telerik:RadPanelBar>

right now the button calls this on the onclick, but this will not be the case later. I can't use the this keyword

function GetbtnTEST(){
var panelbar = $find("<%= RadPanelBar1.ClientID %>");
var item = panelbar.findItemByValue("Travelers");//I need to find by value because we use language files for Text
var objBtn = item.findControl("ColorPicker");
alert(
'objBtn = ' + objBtn);//Always null!
}

Someone please help...this is driving me nuts!

1 Answer, 1 is accepted

Sort by
0
jgig
Top achievements
Rank 1
answered on 03 Oct 2008, 07:31 PM
Figured it out.

Heres the answer to save some other lost soul.

var objBtn = document.getElementById("<%= RadPanelBar1.FindItemByValue("valuestring").FindControl("ControlID").ClientID %>");

the thing that threw me was the whole 

<

telerik:RadPanelBar ID="RadPanelBar1" runat="server">
<Items>
<telerik:RadPanelItem Text="Name" Expanded="true">
<Items>
<telerik:RadPanelItem Value="valuestring">
<ItemTemplate>
.....close tags

make sure you have the value set in the RadPanelItem just above the ItemTemplate, not the one above where you have the Text set. you want to get the second one. Big headache looking for this. I still dont quite get the whole RadPanelItem in a RadPanelItem 100%. I wish they had different names or something so it was less confusing. Seems like your making the Item twice but one is for the PanelItem area that you click and the second is for the area inside of it. Good luck I hope this helps someone!

Tags
PanelBar
Asked by
jgig
Top achievements
Rank 1
Answers by
jgig
Top achievements
Rank 1
Share this question
or