1
votes

I'm using Ext.NET with VS2008, ASP.NET. I have a unique problem for which I have not been able to find any solution.

There is a GridPanel and in the TopBar there is a delete button. The Grid uses RowSelection Model. after selecting the row the user clicks the Delete button. a client side event is raised for confirmation following is the code snippet

<ext:Button ID="btnDelete" runat="server" Text="Delete" Icon="Delete">
                    <DirectEvents>
                        <Click OnEvent="Evt_Delete">
                        <ExtraParams>
                        <ext:Parameter Name="recordId" Value="(#{grdSanction}).selModel.getSelected().data.VoucherID" Mode="Raw" />
                        </ExtraParams>

                            <Confirmation Message="Do you really want to delete sanction?" ConfirmRequest="true"/>
                        </Click>
                    </DirectEvents>
                </ext:Button>

But the problem is that I after clicking yes I get the following message basically a 500 Internal Server Error.

Below is what I find in Fiddler:

Result Protocol Host URL Body Caching Content-Type Process Comments Custom
1 500 HTTP onyx /pages/sanction.aspx?_dc=1337773867270 4,268 private text/html; charset=utf-8 chrome:920

Debugger of VS2008 does not work because the event on the code behind is never raised. other buttons on the toolbar work just fine. Does anyone know what am I missing here?

1

1 Answers

1
votes

I think you just need to remove the round brackets from around the #{grdSantion}.

// Not OK 
(#{grdSanction}).selModel.getSelected().data.VoucherID

// OK
#{grdSanction}.selModel.getSelected().data.VoucherID

The following sample demonstrates the full scenario and appears to work as per your requirements.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!X.IsAjaxRequest)
        {
            var store = this.GridPanel1.GetStore();

            store.DataSource = this.Data;
            store.DataBind();
        }
    }

    private object[] Data
    {
        get
        {
            return new object[]
            {
                new object[] { "3m Co", 71.72, 0.02, 0.03, "9/1 12:00am" },
                new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, "9/1 12:00am" },
                new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, "9/1 12:00am" },
                new object[] { "American Express Company", 52.55, 0.01, 0.02, "9/1 12:00am" },
                new object[] { "American International Group, Inc.", 64.13, 0.31, 0.49, "9/1 12:00am" },
                new object[] { "AT&T Inc.", 31.61, -0.48, -1.54, "9/1 12:00am" },
                new object[] { "Boeing Co.", 75.43, 0.53, 0.71, "9/1 12:00am" },
                new object[] { "Caterpillar Inc.", 67.27, 0.92, 1.39, "9/1 12:00am" }
            };
        }
    }

    protected void Button1_Click(object sender, DirectEventArgs e)
    {
        X.Msg.Notify("Company", e.ExtraParams["company"]).Show();
    }
</script>

<!DOCTYPE html>

<html>
<head runat="server">
    <title>Ext.NET Example</title>
</head>
<body>
<form runat="server">
    <ext:ResourceManager runat="server" />

    <ext:GridPanel 
        ID="GridPanel1"
        runat="server" 
        Title="Array Grid" 
        Width="350" 
        Height="215">
        <TopBar>
            <ext:Toolbar runat="server">
                <Items>
                    <ext:Button runat="server" Text="Delete" Icon="Delete">
                        <DirectEvents>
                            <Click OnEvent="Button1_Click">
                            <ExtraParams>
                                <ext:Parameter Name="company" Value="#{GridPanel1}.selModel.getSelected().data.company" Mode="Raw" />
                            </ExtraParams>
                                <Confirmation Message="Do you really want to delete sanction?" ConfirmRequest="true"/>
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
        </TopBar>
        <Store>
            <ext:Store runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="company" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
        </Store>
        <ColumnModel runat="server">
            <Columns>
                <ext:Column ColumnID="Company" Header="Company" DataIndex="company" />
            </Columns>
        </ColumnModel>
        <SelectionModel>
            <ext:RowSelectionModel runat="server" SingleSelect="true" />
        </SelectionModel>
    </ext:GridPanel>
</form>
</body>
</html>