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

RadPanelBar javascript/jquery issue

6 Answers 150 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
RvdGrint
Top achievements
Rank 1
RvdGrint asked on 17 Jan 2012, 09:23 PM
Hello,

I've a RadPanelBar on a dynamiclly loaded UserControl. In that UserControl I've placed a RadScriptBlock where my javascript functions are defined. I'm trying to execute the get_element() and/or get_items() functions but I always get the error that the function is not supported.
var $ = $telerik.$;
 
var categoryPanelBar = $(this).find("<%=RadPanelBar1.ClientID%>");
 
alert(categoryPanelBar.get_items());

With this code the PanelBar object can be found only the function get_items() will not be excuted because it tells me that this function is not support for the element.

Can someone help me with this?

Regards,
  Jos Meerkerk,

6 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 20 Jan 2012, 10:35 AM
Hello Jos,

You get the following error since the jQuery find method accepts either a selector, a jQuery object or an element while in your case you use none of the just mentioned ones. However, using the following code you can achieve the desired effect:
<telerik:RadScriptBlock runat="server" ID="block1">
    <script type="text/javascript">
        function pageLoad() {
            var categoryPanelBar = $find("<%=RadPanelBar1.ClientID%>");
            var item = categoryPanelBar.findItemByText("item1");
            item.disable();
        }
    </script>
</telerik:RadScriptBlock>

Please note that we would recommend that you use our flexible client-side API.

Regards,
Kate
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
0
RvdGrint
Top achievements
Rank 1
answered on 20 Jan 2012, 10:59 AM
Kate,

thnx for your reply but unfortunately this doesn't work.

When I use:
var categoryPanelBar = $find("<%=RadPanelBar1.ClientID%>");

then categorypPanelBar is null

But when I use:

var categoryPanelBar = $(this).find("<%=RadPanelBar1.ClientID%>");

an [object] is found

But stil the methods are not valid for the object.

The problem occurs with implementing the Telerik Schedule example with WebServices (http://demos.telerik.com/aspnet-ajax/scheduler/examples/webservice/defaultcs.aspx) on a Dynamiclly loaded User Control.

Regards,
  Jos

 

 

 

0
Kate
Telerik team
answered on 21 Jan 2012, 11:42 AM
Hello Jos,

Please refer to the attached runnable page that works as expected from my end (I can find the RadPanelBar object and access its properties). Can you modify it in a way so that it demonstrates the issue so I can help you out?

All the best,
Kate
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
0
RvdGrint
Top achievements
Rank 1
answered on 23 Jan 2012, 08:20 AM
Kate,

as mentioned before my User Control is loaded dynamically. Could that be the difference??
I will try you're example.

Regards,
  Jos Meerkerk
0
RvdGrint
Top achievements
Rank 1
answered on 23 Jan 2012, 08:42 AM
Kate,

with your example everything work's fine. Is there an explanation for the fact that things do not work when implementing it in my application?

Regards,
  Jos
0
Ivana
Telerik team
answered on 25 Jan 2012, 05:42 PM
Hello Jos,

Attached is a sample project which uses the following approach to find a client object of a control which is placed inside a user control:
function pageLoad() {
    var paneljQuery = $telerik.$("[id$='_RadPanelBar1']");
    var panelBarObj = $find(paneljQuery.attr("id"));
    alert("The PanelBar Object: " + panelBarObj.get_id());
    alert("The number of items: " + panelBarObj.get_items().get_count());
}
var paneljQuery = $telerik.$("[id$='_RadPanelBar1']"); -- finds the jQuery object of a control which ID ends on the '_RadPanelBar1' string.

$find(paneljQuery.attr("id")); -- finds the client object of the control which ID is passed as a parameter.

I hope this helps.

Greetings,
Ivana
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
Tags
PanelBar
Asked by
RvdGrint
Top achievements
Rank 1
Answers by
Kate
Telerik team
RvdGrint
Top achievements
Rank 1
Ivana
Telerik team
Share this question
or