Community & Support
Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Docking > Custom Commands, how to pass data on javascript function
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Custom Commands, how to pass data on javascript function

Feed from this thread
  • Posted on Sep 12, 2007 (permalink)

    Hello,

    I dynamically created RadDockableObject  , than i need to add my custom command. I do it on that way:

    RadDockableObjectCommand l_EditCommand = new RadDockableObjectCommand("editWidget");
    l_EditCommand.ToolTip =
    "It is work and edit";
    l_EditCommand.Image =
    "edit.gif";
    l_EditCommand.OnClientCommand =
    "clientEditWidget";
    dockableObject.Commands.Add(l_EditCommand);

    On client:

    function clientEditWidget(dockObj,eventArgs)
    {alert('It is work'); }


    And it is work properly. But i need to pass in clientEditWidget my own argument. Is it possible?

    Thanks.

  • Obi-Wan Kenobi Master avatar

    Posted on Sep 16, 2007 (permalink)

    You can add a hiddenfield to the dockObject.
    On the client(clientEditWidget) you can get the hiddenfield value and use it.

  • ashish avatar

    Posted on Oct 6, 2007 (permalink)

    Can you provide an example ?

  • Petya Petya admin's avatar

    Posted on Oct 8, 2007 (permalink)

    Hello ashish,

    Here is another idea to get the desired scenario. You can add another custom command to the dockable object and set its Enabled property to False so that it does not appear in the control and at the same time set its Tooltip property to the value you want to pass to the OnClientCommand. Then in OnClientCommand you can get the disabled custom command's tooltip value and use it. I am attaching a simple page demonstrating this approach. Here is how it looks like:

    [ASPX]

    <script type="text/javascript">
            function clientEditWidget(dockableObject, command)
            {
                alert(dockableObject.GetCommandByName("MyCustomCommand").title);
            }
            </script>
            <cc1:raddockingmanager id="RadDockingManager1" runat="server" skin="Default" />
            <table>
                <tr>
                    <td>
                        <cc1:raddockingzone id="RadDockingZone1" runat="server" width="172px">
                            <cc1:raddockableobject id="RadDockableObject1" runat="server" text="Dock1">
                            </cc1:raddockableobject>
                            <cc1:raddockableobject id="RadDockableObject2" runat="server" text="Dock2">
                            </cc1:raddockableobject>
                        </cc1:raddockingzone>
                    </td>
                    <td>
                        <cc1:raddockingzone id="RadDockingZone2" runat="server" width="172px">
                        </cc1:raddockingzone>
                    </td>
                </tr>
            </table>

    [C#]

    protected void Page_Load(object sender, EventArgs e)
        {
            RadDockableObjectCommand l_EditCommand = new RadDockableObjectCommand("editWidget");
            l_EditCommand.ToolTip = "It is work and edit";
            l_EditCommand.Image = "edit.gif";
            l_EditCommand.OnClientCommand = "clientEditWidget";
            RadDockableObject2.Commands.Add(l_EditCommand);

            RadDockableObjectCommand hiddenCommand = new RadDockableObjectCommand();
            hiddenCommand.ToolTip = "new value";//the value you need in OnClientCommand
            hiddenCommand.Name = "MyCustomCommand";
            hiddenCommand.Enabled = false;
            RadDockableObject2.Commands.Add(hiddenCommand);
        }

    Hope you find it helpful.

    Regards,
    Petya
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  • ashish avatar

    Posted on Oct 14, 2007 (permalink)

    Hi Petya,

    I was looking for this functionality in prometheus Docking. The enabled property does not exist there, nor does the tooltip.

  • Petya Petya admin's avatar

    Posted on Oct 15, 2007 (permalink)

    Hi ashish,

    You can implement the same idea for RadDock Prometheus with the following modifications:

    [JavaScript]
            <script type="text/javascript">
            function clientEditWidget(
    dock, args)
            {
                alert(dock.getCommand("MyCustomCommand").get_text());
            }
            </script>


    [C#]

           DockCommand editCommand = new DockCommand();
            editCommand.Name = "Edit";
            editCommand.OnClientCommand = "OnClientCommand";
            dock.Commands.Add(editCommand);

            DockCommand hiddenCommand = new DockCommand();
            hiddenCommand.Text = "new value";//the value you need in OnClientCommand
            hiddenCommand.Name = "MyCustomCommand";
            hiddenCommand.CssClass = "hideClass";
            dock.Commands.Add(hiddenCommand);

    We pass the desired value to the Text property of the custom command. This time we will hide the hiddenCommand with CSS using its CssClass property. You can declare the following style in the head of your page:

    [ASPX]

    <style type="text/css">
        .hideClass
        {
            display:none;
        }
        </style>

    Let me know if you still have problems with this.

    Kind regards,
    Petya
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  • ashish avatar

    Posted on Oct 15, 2007 (permalink)

    I get a java script error

    sender.GetCommand("UserControl).get_text is not a function

    This is my code snippet.

    I had removed the css value and the alt text of the command button does show the desired value. But the javascript function getcommand("UserControl").get_text() does not get the value.



    Dim hiddencommand As New DockCommand()  
     
            hiddencommand.Text = uc 
            hiddencommand.Name = "UserControl" 
            hiddencommand.CssClass = "hideClass" 
            dock.Commands.Add(hiddencommand) 


     function OpenDetail(sender, args)  
            {  
               // var oWnd = window.radopen(null, "RadWindow1");  
              // alert ("ff");  
                alert(sender.getCommand("UserControl").get_text());  
     
              // var s = sender.get_parent();  
              // var t = s.split("_",2);  
              // alert (args.Command.get_element());  
              // alert (t[1]);  
                 
                
                 
              // var oWnd = window.radopen("http://10.20.3.61/detail.aspx?module="+ sender.getCommand("UserControl").get_text() , "RadWindow1");  
     
              //  oWnd.Argument = sender.get_parent();  
                //return false;  
            } 


  • ashish avatar

    Posted on Oct 15, 2007 (permalink)

    OK! it was get_Text (capital T)

  • Petya Petya admin's avatar

    Posted on Oct 16, 2007 (permalink)

    Hello ashish,

    As far as I understand from your last post you have everything working now. In case I am misunderstanding and you still have some problems, please contact us again.

    Greetings,
    Petya
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Docking > Custom Commands, how to pass data on javascript function