(ext.net)如何双击列表视图后面的代码项

时间:2012-06-09 05:08:58

标签: c# ext.net

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

1 个答案:

答案 0 :(得分: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>