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

Dynamic Custom Doc Command

5 Answers 81 Views
Window
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 2
Stephen asked on 21 Nov 2008, 01:16 AM
Anyone have any suggestions on how to add a dock command server-side. I'm creating the commands on the fly and want to add a "reload" button (there is one on the RadWindow) and then handle that myself. But I can't seem to create a DockCommand.
Telerik.Web.UI.DockCommand.DockCommand(string, string, string, string, bool)' is inaccessible due to its protection level   


5 Answers, 1 is accepted

Sort by
0
Vyrban
Top achievements
Rank 1
answered on 21 Nov 2008, 01:30 PM
Hi Stephen,

You can use this:
dock.Commands.Add(new DockCloseCommand());  
dock.Commands.Add(new DockExpandCollapseCommand());  
dock.Command += new DockCommandEventHandler(dock_Command);  
 
//..........  
 
void dock_Command(object sender, DockCommandEventArgs e)  
{  
//.......  
The code is form Telerik online RadDock example "My portal".
0
Stephen
Top achievements
Rank 2
answered on 21 Nov 2008, 01:46 PM
I think I had seen that. What I want to do is add a new command. I think what you described just adds the command from the existing set (Close, Pin, Expand/Collapse). I need to add a new icon to enable different functionality. If you think I can do that with what you suggested I'll look over that again as I must be missing something.
0
Vyrban
Top achievements
Rank 1
answered on 21 Nov 2008, 03:57 PM
Hi Stephen,

Of course these are the default commands. For Custom Command "Reload" You can use this code:
protected void Page_Load(object sender, EventArgs e)  
    {  
        DockCommand command = new DockCommand();  
        command.Name = "Reload";  
        RadDock1.Command += new DockCommandEventHandler(RadDock1_Command);  
        RadDock1.Commands.Add(command);  
        RadDock1.CommandsAutoPostBack = true;  
    }  
 
    void RadDock1_Command(object sender, DockCommandEventArgs e)  
    {  
        if (e.Command.Name == "Reload")  
        {  
            //Do what is supposed to do     
        }  
    } 
Think this will help you :)
0
Unified Development
Top achievements
Rank 1
answered on 09 Feb 2010, 05:52 PM
I have almost this exact code and for the life of me I can't get the function to fire, the page never posts back.

Do you see anything wrong here?

RadDock rd = new RadDock();
        rd.ID = usage + "_" + "FORM_" + loadedForm.getID() + "_" + ff.getFormFieldID() + "_" + ffs.getFormFieldSettingsID();
        rd.DockMode = DockMode.Docked;
        rd.DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.None;
        rd.Width = 300;
        rd.Height = 80;
        rd.AutoPostBack = true;
        rd.CommandsAutoPostBack = true;

        rd.Command += new DockCommandEventHandler(Dock_Command);

        DockCommand command = new DockCommand();
        command.AutoPostBack = true;
        command.Name = "Command1";
        command.Text = "Command1";

        rd.Commands.Add(command);

And here is the event

protected void Dock_Command(object sender, DockCommandEventArgs e)
    {
        Response.Redirect("alskfj alsdjf lasj lasdjf lasjfk");
    }

The redirect never fires, why?

Thanks,
Derek

0
Pero
Telerik team
answered on 12 Feb 2010, 12:48 PM
Hi Derek,

Please check at what stage in the page lifecycle the dock is added to the page. If it's added after the Command event is triggered the code will never be executed.

I created a sample project and could not reproduce the problem. It is attached to the thread.

Kind regards,
Pero
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.
Tags
Window
Asked by
Stephen
Top achievements
Rank 2
Answers by
Vyrban
Top achievements
Rank 1
Stephen
Top achievements
Rank 2
Unified Development
Top achievements
Rank 1
Pero
Telerik team
Share this question
or