Skip to content
This repository was archived by the owner on Aug 9, 2024. It is now read-only.
This repository was archived by the owner on Aug 9, 2024. It is now read-only.

Direct Events not passing control scope to client-side environment #1842

Description

@fabriciomurta

Found: 7.1.0
Ext.NET forum thread:

Generated client-side code is not including a required control: this argument to Ext.net.directRequest() calls.

The following code in Ext.NET 5:

<ext:button runat="server" text="Toast 2">
    <directEvents>
        <click OnEvent="Button2_Click">
            <extraParams>
                <ext:Parameter name="label" value="function() { return this.text; }" mode="Raw" />
            </extraParams>
        </click>
    </directEvents>
</ext:button>

Results in:

Ext.create("Ext.button.Button", {
    id: "ctl03",
    renderTo: "App.ctl03_Container",
    text: "Toast 2",
    directEvents: {
        click: {
            fn: function (item, e) {
                Ext.net.directRequest({
                    extraParams: {
                        "label": function () {
                            return this.text;
                        }
                    },
                    control: this
                });
            }
        }
    }
});

In Ext.NET 7 though, the button definition:

<ext-button text="Toast 2">
    <directEvents>
        <click actionName="Button2_Click">
            <extraParams>
                <ext-add key="label" value="function() { return this.text; }" mode="Raw" />
            </extraParams>
        </click>
    </directEvents>
</ext-button>

Is generating:

Ext.create("Ext.button.Button", {
    directEvents: {
        click: {
            fn: function (item, e) {
                Ext.net.directRequest({
                    action: "click",
                    cleanRequest: true,
                    extraParams: {
                        label: function () {
                            return this.text;
                        }
                    }
                });
            }
        }
    },
    id: "ctl02",
    renderTo: "App.ctl02_Container",
    text: "Toast 2"
});

Then, this in the direct event's extraParams scope becomes the javascript Window object, and it is not possible to reliably get data from the related component during pre- and post- direct event client-side tasks.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions