GridPanel SelectedRows.Count always returning 0

  1. #1

    GridPanel SelectedRows.Count always returning 0

    I'm using Ext.NET 2.1, as retrieved through NuGet earlier today.

    I have a window with a textbox and a button.

    When I click on the button, a window pops up and shows a grid of data. The data is coming from an ASP.NET WebAPI, returned in JSON format, and this part of the process appears to work fine.

    Eventually, the idea is that the user will double-click one of the grid rows, the value in the first column will pass back to the textbox, and the window will close.

    At this stage, I'm just trying to get a count of the selected rows, after the user double-clicks a row. Given my RowSelectionModel Mode is set to "Single", I would expecta value of "1" to be returned when I double-click a row.

    However, the code is always returning "0".

    I'm new to Ext.NET, so it's probably something simple ... any help would be appreciated!

    See code below:

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
    
        protected void Item_DoubleClick(object sender, DirectEventArgs e)
        {
            RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
    
            this.txtBuildingGroupId.Text = sm.SelectedRows.Count.ToString();
            this.Window1.Hide();
        }
    
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head id="Head1" runat="server">
        <title>AJAX Request to HttpHander returns Json</title>
    </head>
    
    <body>
    
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
        <ext:TextField ID="txtBuildingGroupId" runat="server" />
        <ext:Button
            ID="Button1"
            runat="server"
            Text="Search">
            <Listeners>
                <Click Handler="#{Window1}.show()" />
            </Listeners>
        </ext:Button>
    
        <ext:Store runat="server" ID="Store1">
            <Proxy>
                <ext:AjaxProxy Url="http://localhost:1581/api/buildinggroups">
                    <ActionMethods Read="GET" />
                    <Reader>
                        <ext:JsonReader IDProperty="BuildingGroupId" />
                    </Reader>
                </ext:AjaxProxy>
            </Proxy>
            <Model>
                <ext:Model ID="Model1" runat="server">
                    <Fields>
                        <ext:ModelField Name="BuildingGroupId" Type="String" />
                        <ext:ModelField Name="Name" Type="String" />
                        <ext:ModelField Name="RowId" Type="String" />
                    </Fields>
                </ext:Model>
            </Model>
            <Sorters>
                <ext:DataSorter Property="BuildingGroupId" Direction="ASC" />
            </Sorters>
        </ext:Store>
        
        <ext:Window ID="Window1"
            runat="server"
            Collapsible="false"
            Title="Search Database for : Building Groups"
            Height="500"
            Width="800"
            Layout="Fit"
            Hidden="true">
            <Items>
                <ext:GridPanel
                    ID="GridPanel1"
                    runat="server"
                    AutoExpandColumn="Name"
                    Frame="false"
                    StoreID="Store1">
                    <ColumnModel ID="ColumnModel1" runat="server">
                        <Columns>
                            <ext:Column runat="server" ColumnID="BuildingGroupId" Header="Building Group" DataIndex="BuildingGroupId" Width="220" />
                            <ext:Column runat="server" Header="Name" DataIndex="Name" Flex="1" />
                            <ext:Column runat="server" Header="Row ID" DataIndex="RowId" Width="130" Visible="false" />
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Single" />
                    </SelectionModel>
                    <DirectEvents>
                        <ItemDblClick OnEvent="Item_DblClick" />
                    </DirectEvents>
                </ext:GridPanel>
            </Items>
        </ext:Window>
    
    </body>
    </html>
  2. #2
    Nevermind, I worked it out.

    I'm missing the <form runat="server"> stuff.

    Told you I was new to this ;-)

Similar Threads

  1. Replies: 2
    Last Post: Nov 29, 2012, 9:30 AM
  2. Replies: 1
    Last Post: Oct 16, 2012, 9:19 AM
  3. [CLOSED] How to get selectedrows of gridpanel
    By egvt in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 31, 2012, 7:10 PM
  4. Replies: 13
    Last Post: Mar 29, 2012, 2:39 PM
  5. Replies: 0
    Last Post: Dec 29, 2008, 8:19 AM

Tags for this Thread

Posting Permissions