radtoolbar AT RUNTIME and $find javascript

2 posts, 0 answers
  1. Marco Silva
    Marco Silva avatar
    3 posts
    Member since:
    Jun 2009

    Posted 01 Apr 2010 Link to this post

    I created a radtoolbar AT RUNTIME
    But the javascript $find method does not find it.
    That is the javascript code:

      function pesquisar(e) {
            if (e.keyCode == 13)
            {
                //radtoolbar is a runtime created RadToolBar
                //but can´t be found...
                var toolBar = $find("<%= radtoolbar.ClientID %>");
     
                //here the toolBar IS NULL and causes an error.
                var item = toolBar.findItemByText('Pesquisar');
     
                if (Telerik.Web.UI.RadToolBarButton.isInstanceOfType(item)) {
                    item.click();
                }
             }
        }

    I tried the getelementbyid method, but this does not return a Telerik.Web.UI.RadToolBarButton, but a [ObjectHtml DivElement].
    So, the toolBar.findItemByText('Pesquisar') can´t be executed.
    the javascript code:

      function pesquisar(e) {
            if (e.keyCode == 13)
            {
                // the getElementById does not return a RadToolBarButton
                var toolBar = document.getElementById("radtoolbar");
           
                var item = toolBar.findItemByText('Pesquisar');
                if (Telerik.Web.UI.RadToolBarButton.isInstanceOfType(item)) {
                    item.click();
                }
             }
        }

    But when I use a design time RadToolBar created, the $find method works fine

  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 02 Apr 2010 Link to this post

    Hi Marco Silva,

    I already replied to your support thread:

    It depends when exactly you call the pesquisar() method. Maybe you call it too early and the toolbar is still not created/initialized? You might find this blog post useful.

    Best wishes,
    Veskoni
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top