Change Dock Title

7 posts, 0 answers
  1. Mark Davison
    Mark Davison avatar
    82 posts
    Member since:
    Jul 2005

    Posted 22 Jun 2007 Link to this post

    Hi,

    Can a docks title be changed dynamically using JS on the client?

    Thanks!

    Mark
  2. Petya
    Admin
    Petya avatar
    869 posts

    Posted 22 Jun 2007 Link to this post

    Hello Mark Davison,

    Here is how to get/set the title client-side:

    <telerik:raddock id="RadDock3" runat="server"  height="280px" title="Dock3" width="200px">
    </telerik:raddock>
    <input id="Button1" onclick="changeTitle()" type="button" value="Change title" />

     <script type="text/javascript">
    function changeTitle()
        {
           var dock = $find('<%= RadDock3.ClientID%>');
           alert(dock.get_Title());
           dock.set_Title("New title");
        }
       
        Telerik.Web.UI.RadDock.prototype.get_Title = function()
        {
            return $get(this.get_TitlebarContainerID()).getElementsByTagName('em')[0].innerHTML;
        }
        Telerik.Web.UI.RadDock.prototype.set_Title = function(value)
        {
            return $get(this.get_TitlebarContainerID()).getElementsByTagName('em')[0].innerHTML = value;
        }
     </script>

    Kind regards,
    Petya
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Mark Davison
    Mark Davison avatar
    82 posts
    Member since:
    Jul 2005

    Posted 22 Jun 2007 Link to this post

    Hi Petya,

    This is not quite working for me! The code runs without error but the title of the dock is not changing. If I do a get_Title after the set_Title, it tells me the new title correctly. It just appears that the dock it not updating it's title.

    Do you have any ideas?

    Regards,

    Mark
  4. Mark Davison
    Mark Davison avatar
    82 posts
    Member since:
    Jul 2005

    Posted 22 Jun 2007 Link to this post

    I also get "Telerik is undefined" when the page loads for the first time.
  5. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 25 Jun 2007 Link to this post

    Hello Mark,

    The attached page works on my side. Let me know if we are missing something

    Regards,
    Valeri Hristov (Senior Developer, MCSD)
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Matt
    Matt avatar
    2 posts
    Member since:
    Nov 2006

    Posted 02 Jul 2007 Link to this post

    This is how I'm doing it.  Its a slightly modified version of a JS function in the ASP.NET Dock form

     function changeDockableObjectTitle(rdoObjID, newTitle)  
     {  
      var dockableObjectId = rdoObjID;  
      var titleCell = document.getElementById(dockableObjectId);  
      var emTag = titleCell.getElementsByTagName("em");  
        
      if (emTag)  
      {  
       emTag[0].innerHTML = newTitle;  
      }  
     } 
  7. Mark Davison
    Mark Davison avatar
    82 posts
    Member since:
    Jul 2005

    Posted 02 Jul 2007 Link to this post

    Hi Matt,

    I came up with the same solution as you after looking at Teleriks code. It works perfectly!

    Regards,

    Mark
Back to Top