Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
fabriciomurta opened this issue Nov 18, 2020 · 1 comment
Closed
Assignees
Milestone

Comments

@fabriciomurta
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants