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

Using MediaManager within custom control but hide it from the default toolbar

1 Answer 20 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 22 Nov 2013, 01:02 PM
Hi,

we have our own custom control to insert flash and video into the website. Within the control we are using the media manager to let the user choose the files.
The problem we have is that we want to hide the media manager icon from the default toolbar but still be able to open the media manager from within our custom control.
If we remove the mediamanager entry in the ToolFile.xml the media manager also won't open in our custom control.
If we leave it there it works, but the default media manager icon is still present.

Is there any possibility to just hide the default media manager icon?

Thanks
Mark

1 Answer, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 27 Nov 2013, 10:44 AM
Hi Mark,

The described behavior occurs because of optimization matters. When a dialog tool is not defined in the toolbar, its Dialog Definitions are not being registered.

To workaround this issue and use the desired dialog only in the custom dialogs you could set the Visibility property of the tool to false, so that it appears defined in the toolbar, but it would be not visible to the user.

Please follow either of these approaches to achieve the desired functionality:
  • If the tool is set in the editor's markup you could use the Visible property of the tool:
    <telerik:RadEditor runat="server" ID="RadEditor1">
        <Tools>
            ...
            <telerik:EditorToolGroup>
                ...
                <telerik:EditorTool Name="MediaManager" Visible="false" />
                ...
            </telerik:EditorToolGroup>
            ...
        </Tools>
    </telerik:RadEditor>
  • In case that the tool is set in the ToolsFile.xml file you could use JavaScript, C# or VB approach:

    JavaScript example:
    <telerik:RadEditor runat="server" ID="RadEditor1"
        ToolsFile="ToolsFile.xml" OnClientLoad="OnClientLoad">
    </telerik:RadEditor>
     
    <script type="text/javascript">
        function OnClientLoad(editor, args) {
            var toolAdapter = editor.get_toolAdapter();
            var mediaTool = toolAdapter.getToolByName("MediaManager");
            mediaTool.set_visible(false);
        }
    </script>

    C# example:
    protected void Page_Load(object sender, EventArgs e)
    {
        EditorToolGroupCollection tools = RadEditor1.Tools;
        string toolName = "MediaManager";
        for (int i = 0; i < tools.Count; i++)
        {
            if (tools[i].Contains(toolName))
            {
                EditorTool mediaTool = tools[i].FindTool(toolName);
                mediaTool.Visible = false;
            }
        }
    }

    VB example:
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim tools As EditorToolGroupCollection = RadEditor1.Tools
        Dim toolName As String = "MediaManager"
     
        For Each toolGroup As EditorToolGroup In tools
            If toolGroup.Contains(toolName) Then
                Dim tool As EditorTool = toolGroup.FindTool(toolName)
                tool.Visible = False
            End If
     
        Next
    End Sub

Regards,
Ianko
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Editor
Asked by
Mark
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Share this question
or