1

在 ext.net 库中,如何从服务器端代码中获取列表视图中的双击项目?我有一个多选列表视图,但我想添加额外的功能来双击和项目并显示有关它的一些详细信息。谢谢

4

1 回答 1

0

尝试使用这个:

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e) {
            if (!X.IsAjaxRequest) {
                this.Store1.DataSource = this.Data;
                this.Store1.DataBind();
            }
        }

        private object[] Data {
            get {
                return new object[]
            {
                new { header = "3m Co" },
                new { header = "Coca Cola" },
                new { header = "Pepsi Co" },
            };
            }
        }

        protected void ShowHello(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("Hello", "Hello " + e.ExtraParams["SayHelloTo"]).Show();
        }

    </script>
</head>
<body>
    <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />

        <ext:ListView 
                    ID="ListView1" 
                    runat="server"
                    MultiSelect="true"
                    ReserveScrollOffset="true">
            <DirectEvents>
                <DblClick OnEvent="ShowHello">
                    <ExtraParams>
                        <%--Sending Extra Params, which will contain header value, don't forget to set mode to Raw
                        All other properties you can find in item.getStore().data.items[index].data--%>
                        <ext:Parameter runat="server" Name="SayHelloTo" Value="item.getStore().data.items[index].data.header" Mode="Raw"></ext:Parameter>
                    </ExtraParams>
                </DblClick>
            </DirectEvents>
                    <Store>
                        <ext:Store ID="Store1" runat="server">
                            <Reader>
                                <ext:JsonReader IDProperty="header">
                                    <Fields>
                                        <ext:RecordField Name="header" />
                                    </Fields>
                                </ext:JsonReader>
                            </Reader>
                        </ext:Store>
                    </Store>
                    <Columns>
                        <ext:ListViewColumn 
                            Header="Header" 
                            Width="1" 
                            DataIndex="header"  
                            />
                    </Columns> 
                </ext:ListView>
   </form>
</body>
</html>
于 2012-06-16T09:55:15.447 回答