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

Examples for DockToggleCommand

4 Answers 107 Views
Dock
This is a migrated thread and some comments may be shown as answers.
bp
Top achievements
Rank 1
bp asked on 27 May 2007, 05:29 AM
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.

4 Answers, 1 is accepted

Sort by
0
bp
Top achievements
Rank 1
answered on 29 May 2007, 04:52 AM
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.
0
Valeri Hristov
Telerik team
answered on 04 Jun 2007, 11:30 AM
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
0
bp
Top achievements
Rank 1
answered on 04 Jun 2007, 04:25 PM
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
0
Daniel
Top achievements
Rank 1
answered on 29 Dec 2007, 12:05 AM
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);
}
Tags
Dock
Asked by
bp
Top achievements
Rank 1
Answers by
bp
Top achievements
Rank 1
Valeri Hristov
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or