Examples for DockToggleCommand

5 posts, 0 answers
  1. bp
    bp avatar
    3 posts
    Member since:
    May 2007

    Posted 27 May 2007 Link to this post

    Do you have any examples on how to create a custom DockToggleCommand?  I am having problems updating the state after each click.  Also, is there a way to use text instead of an image to represent the dock button?  Thanks in advance for help.
  2. bp
    bp avatar
    3 posts
    Member since:
    May 2007

    Posted 28 May 2007 Link to this post

    I noticed that all the built in commands seem to have corresponding settings in RadDock. Is this where the command state is persisted?  Does that mean that i need to overload RadDock, DockState and DockToggleCommand to get a custom Toggle Command? Any help would be appreciated. Thanks.
  3. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 04 Jun 2007 Link to this post

    Hello bp,

    Please, accept my sincere apologies for the delay of my reply. Attached is the requested example.

    I should note that the latest update of RadDock (version 2007.01.0521.0) has a bug, which prevents the commands from proper operation when their state is initially set to Alternate. Please, use the build from the following forum thread if you intend to have commands with initial Alternate state.
    http://www.telerik.com/community/forums/thread/b311D-mkedd.aspx

    You cannot use text instead of image for the command items. However, you could use image which has some text inside, but this will complicate the translation of the application to other languages.

    For simple scenarios you do not need to overload anything. You could just handle the ClientCommand client-side event and perform the needed actions there. For complex scenarios you could overload the DockToggleCommand class server and client-side. This will minimize the control output, encapsulate the logic and could be placed in a separate javascript file. Let me know if you need an example for this and I will provide one.

    All the best,
    Valeri Hristov (Senior Developer, MCSD)
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  4. bp
    bp avatar
    3 posts
    Member since:
    May 2007

    Posted 04 Jun 2007 Link to this post

    Hi Valeri-
    Thank you for the example, but when i run use it the alternate CSS and alternate text are never used, the Command behavior now works as expected. If you wouldn't mind, i would appreciate an overload example.

    thank you very much,
    -bp
  5. Daniel
    Daniel avatar
    44 posts
    Member since:
    Nov 2007

    Posted 28 Dec 2007 Link to this post

    For anyone landing on this thread as of 'Prometheus' Q3, DockToggleCommand's OnClientCommand event no longer functions as the example is given.

    The method signature in the example demonstrates toggling state on the client as follows:

    function OnClientCommand(command, args)
    {
        // Toggling the state on the client-side
       command.set_State(command.get_State() == 1 ? 2 : 1);
    }

    As of Prometheus 2007 Q3, this command actually returns the RadDock object, and the Command property is now on the args object, so if you want to change state of a custom DockToggleCommand, use this approach instead:

    function OnClientCommand(dock, args)
    {
        // Toggling the state on the client-side
        args.Command.set_State(args.Command.get_State() == 1 ? 2 : 1);
    }
Back to Top