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

RadEditor Issue changing state of tool button

2 Answers 87 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Adonis
Top achievements
Rank 1
Adonis asked on 07 Jan 2012, 02:42 PM
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 Answers, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 09 Jan 2012, 06:21 PM
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.
0
Accepted
Rumen
Telerik team
answered on 11 Jan 2012, 08:33 AM
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
Tags
Editor
Asked by
Adonis
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or