RadEditor Issue changing state of tool button

3 posts, 1 answers
  1. Adonis
    Adonis avatar
    34 posts
    Member since:
    Nov 2008

    Posted 07 Jan 2012 Link to this post

    I have the follow script to disable a button in the toolbar , I switch edit modes pragmatically based of some conditions the section for preview mode works fine but the section for design mode does not any help is appreciated. 

    <script type="text/javascript">
            function OnClientModeChange(editor, args) {
                var mode = editor.get_mode();
                switch (mode) {
                    case 1:
                        //Design MODE
                        setTimeout(function () {
                            var tool = editor.getToolByName("ChangeRequest");
                            tool.setState(-1);
                        }, 0);
                        break;
                    case 2:
                       //HTML
                        
                        break;
                    case 3:
                        
                        break;
                    case 4:
                       setTimeout(function () {
                            var tool = editor.getToolByName("ChangeRequest");
                            tool.setState(0);
                        }, 0);
                     
                        break;
                }
            }
        </script>
  2. Richard
    Richard avatar
    479 posts
    Member since:
    Nov 2011

    Posted 09 Jan 2012 Link to this post

    Adonis:

    I believe that you'd need to set the Toolbar button's "IsEnabled" property to accomplish your requirement.

    See "IsEnabled Property" for insights.

    Hope this helps.
  3. Answer
    Rumen
    Admin
    Rumen avatar
    14432 posts

    Posted 11 Jan 2012 Link to this post

    Hi,

    If you want to disable your custom button when the editor loads in Design mode you should do that in the OnClientLoad event:

    <telerik:RadEditor runat="server" ID="RadEditor1" OnClientModeChange="OnClientModeChange" OnClientLoad="OnClientLoad">
        <Tools>
            <telerik:EditorToolGroup>
                <telerik:EditorTool Name="ChangeRequest" />
            </telerik:EditorToolGroup>
        </Tools>
    </telerik:RadEditor>
    <script type="text/javascript">
        function OnClientLoad(editor) {
            var tool = editor.getToolByName("ChangeRequest");
            tool.setState(-1);
        }
        function OnClientModeChange(editor, args) {
            var mode = editor.get_mode();
            switch (mode) {
                case 1:
                    //Design MODE
                    setTimeout(function () {
                        var tool = editor.getToolByName("ChangeRequest");
                        tool.setState(-1);
                    }, 0);
                    break;
                case 2:
                    //HTML
     
                    break;
                case 3:
     
                    break;
                case 4:
                    setTimeout(function () {
                        var tool = editor.getToolByName("ChangeRequest");
                        tool.setState(0);
                    }, 0);
     
                    break;
            }
        }
    </script>


    Greetings,
    Rumen
    the Telerik team
    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 their blog feed now
Back to Top