Unplanned
Last Updated: 11 Apr 2025 14:26 by Michela
Scheduled for 2025 Q2 (May)
Michela
Created on: 09 Apr 2025 14:12
Category: Editor
Type: Bug Report
1
OnClientCommandExecuting args error TreeList

Hi 

I have a RadEditor control where some toolbar functionalities are not working.

After searching for a possible reason, I used the OnClientCommandExecuting client-side event and noticed that sometimes, instead of the args with its value, I found the item of a RadTreeList control present on the page.

I tried to reproduce the issue by inserting an Editor and a TreeList on a page. I write some text in the Editor and try to change the color or background. Not always (and I can't figure out when), but sometimes the args are incorrect.

For example, if I open a node of the tree, the error is almost certain after that.

I send you an image of my javascript debugger.

I don't know what I can do, do you have any ideas?

Thanks

Michela

Attached Files:
5 comments
Michela
Posted on: 11 Apr 2025 14:26

Thank you, the issue has now been successfully resolved!

Michela

ADMIN
Rumen
Posted on: 11 Apr 2025 13:36

Hi Michela,

I have good news that we found a solution for the reported case. Please put the following raiseEvent function override above the RadEditor declaration and let me know the result.

        <script>
            Telerik.Web.UI.EditorButton.prototype.raiseEvent = function (eventName, eventArgs) {
                var handler = this.get_events().getHandler(eventName);

                if (handler) {
                    if (!eventArgs) {
                        eventArgs = new Sys.EventArgs();
                    }

                    handler(this, eventArgs);
                }
            }
            function OnClientCommandExecuting(editor, args) {

                alert(args.get_value());

            }
    </script>
    <telerik:RadEditor RenderMode="Lightweight" runat="server" ID="RadEditor1" Height="600px" OnClientCommandExecuting="OnClientCommandExecuting">

Regards,
Rumen
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

ADMIN
Rumen
Posted on: 10 Apr 2025 15:34

Hi Michela,

Thank you for the additional details!

I've reproduced the issue and converted the support ticket into a public bug report so the community is aware. I'll need a bit more time to investigate whether there's a reliable workaround, and I'll share any findings here.

As a small token of appreciation for your valuable feedback, I've also updated your Telerik points.

    Regards,
    Rumen
    Progress Telerik

    Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

    Michela
    Posted on: 09 Apr 2025 16:17
    Hi,
    my problem seems to be with args.value.
    For testing, I tried to "skip" if the argument comes in wrong, but by doing so, I can't modify the text in the editor.
    I need the TreeList and the editor to be on the same page.
     if (!args || !args.get_commandName || typeof args.get_commandName !== "function") return;
    
     if (args.get_value() && Telerik.Web.UI.TreeListDataItem.isInstanceOfType(args.get_value()) == true) {
         console.log("ERRORE"); return;
     }
    
     var name = args.get_name();
     var val = args.get_value();
    Michela
    ADMIN
    Rumen
    Posted on: 09 Apr 2025 15:04

    Hi Michela,

    Thank you for the detailed report and the screenshot.

    From what you've described and based on the image you shared, it looks like the problem is related to an incorrect args object being passed to the OnClientCommandExecuting event handler of the RadEditor. The problem looks similar to the one discussed in this KB article: args.get_name is not a function when executing the OnClientCommandExecuting event.

    In particular, the args you're receiving in certain cases appears to be a TreeListDataItem, rather than the expected EditorCommandEventArgs. This can result in errors like:

    Uncaught TypeError: args.get_commandName is not a function

    To resolve this, we recommend updating your event handler to include a type check before attempting to access the properties or methods on the args object. For example:

    <script>
        function OnClientCommandExecuting(editor, args) {
            debugger;
            if (!args || !args.get_commandName || typeof args.get_commandName !== "function") return;
    
            var name = args.get_name();
            var val = args.get_value();
            var cArea = editor.get_contentArea();
            var selectedElement = editor.getSelectedElement();
        }
    </script>

    This approach ensures that the handler only runs when the correct args object is present, preventing the type error and allowing your toolbar functionality (like changing the background color) to work reliably.

    Please try implementing the solution and let us know if the issue persists or if you need further assistance. We're happy to help!

    Regards,
    Rumen
    Progress Telerik

    Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!