[CLOSED] How to check the items in the GridPanel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] How to check the items in the GridPanel

    Hi Community !

    Please check the code sample below:

    
    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Collections.Generic" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = new object[]
                {
                    new object[] { 1, "3m Co", "Blue"},
                    new object[] { 2, "Alcoa Inc", "Blue"},
                    new object[] { 3, "Altria Group Inc", "Red" },
                    new object[] { 4, "American Express Company", "Red"},
                    new object[] { 5, "American International Group, Inc.", "Red" },
                    new object[] { 6, "AT&T Inc.", "Yellow" },
                    new object[] { 7, "Boeing Co.", "Yellow" },
                    new object[] { 8, "Caterpillar Inc.", "Green" },
                    new object[] { 9, "Citigroup, Inc.", "Green" },
                    new object[] { 10, "E.I. du Pont de Nemours and Company",  "Green" }
                };
    
                this.Store1.DataBind();
            }
       }
        protected void Button1_Click(object sender, DirectEventArgs e)
        {
            try
            {
                //var record = Store1.GetById("1");
                //I can't find the way to make it work.
                //GridPanelPuntosPartidas.GetSelectionModel().Select(??, true);
                
                GridPanel1.GetSelectionModel().Select(1, true);
            }
            catch (Exception)
            {
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    
    <head id="Head1" runat="server">
        <title>GridPanel with Checkbox Selection Model - Ext.NET Examples</title>
    </head>
    
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            <ext:Viewport ID="ViewPort1" runat="server" Layout="BorderLayout">
                <Items>
                   
                    <ext:GridPanel ID="GridPanel1" runat="server"
                            Title="Company List"
                            LockText="Bloquear"
                            UnlockText="Desbloquear"
                            MarginSpec="0 5 5 0"
                            SelectionMemory="false"
                            ForceFit="true"
                            Region="Center"
                            Border="False"
                            Frame="true"
                            EnableColumnHide="true">
                        <TopBar>
                            <ext:Toolbar ID="Toolbar1" runat="server">
                                <Items>
                                    <ext:ToolbarFill ID="ToolbarFill1" runat="server"></ext:ToolbarFill>
                                    <ext:Button ID="Button1" runat="server" Icon="Find" Text="Find">
                                        <DirectEvents>
                                            <Click OnEvent="Button1_Click">
                                            </Click>
                                        </DirectEvents>
                                    </ext:Button>
                                </Items>
                            </ext:Toolbar>
                        </TopBar>                    
                        
                        <Store>
                            <ext:Store ID="Store1" runat="server" PageSize="10">
                                <Model>
                                    <ext:Model ID="Model1" runat="server" IDProperty="ID">
                                        <Fields>
                                            <ext:ModelField Name="ID" />
                                            <ext:ModelField Name="Name" />
                                            <ext:ModelField Name="Colour" />
                                        </Fields>
                                    </ext:Model>
                                </Model>
                            </ext:Store>
                        </Store>
    
                        <ColumnModel ID="ColumnModel1" runat="server">
                            <Columns>
                                <ext:Column ID="Column1" runat="server" Text="Company" Width="160" DataIndex="Name" Flex="1" />
    
                                <ext:Column ID="Column2" runat="server" Text="Colour" Width="160" DataIndex="Colour" Flex="1" />
                            </Columns>
                        </ColumnModel>
    
                        <SelectionModel>
                            <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" Mode="Multi" />
                        </SelectionModel>
    
                    </ext:GridPanel>
    
                </Items>
            </ext:Viewport>
        </form>
      </body>
    </html>
    I get a set of records through consulting the database, these records should correspond
    to the items selected in the GridPanel.

    But what I've tried hasn't worked and I don't know how to select the right item without
    having to go through the store.

    var record = Store1.GetById("1");

    I can't find the way to make it work.

    GridPanelPuntosPartidas.GetSelectionModel().Select (??, true);

    Thank you for your help!
    Last edited by fabricio.murta; Dec 11, 2017 at 5:49 PM.

Similar Threads

  1. Replies: 3
    Last Post: Dec 22, 2014, 4:05 PM
  2. [CLOSED] check all MultiCombo items from javascript
    By prost in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 15, 2013, 11:55 AM
  3. [CLOSED] How to check some items in GridPanel? Thanks in advance
    By egvt in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 30, 2012, 4:57 PM
  4. How we can check Duplicate entries in Gridpanel?
    By NishaLijo in forum 1.x Help
    Replies: 3
    Last Post: Jun 03, 2011, 9:57 AM
  5. Replies: 2
    Last Post: Mar 21, 2010, 1:18 PM

Posting Permissions