1

我将 Ext.NET 与 VS2008、ASP.NET 一起使用。我有一个独特的问题,我无法找到任何解决方案。

有一个 GridPanel,在 TopBar 中有一个删除按钮。Grid 使用 RowSelection 模型。选择行后,用户单击删除按钮。引发客户端事件以进行确认以下是代码片段

<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>

但问题是我在单击“是”后收到以下消息,基本上是 500 内部服务器错误。

以下是我在 Fiddler 中找到的内容:

结果 协议 主机 URL 正文 缓存 内容类型 进程 注释 自定义
1 500 HTTP onyx /pages/sanction.aspx?_dc=1337773867270 4,268 私有文本/html;字符集=utf-8 铬:920

VS2008 的调试器不起作用,因为后面代码上的事件永远不会引发。工具栏上的其他按钮工作得很好。有谁知道我在这里想念什么?

4

1 回答 1

1

我认为您只需要从#{grdSantion}.

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

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

以下示例演示了完整方案,并且似乎可以根据您的要求工作。

例子

<%@ 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>
于 2012-05-23T19:39:04.683 回答