[CLOSED] Clearing the CheckboxSelectionModel

  1. #1

    [CLOSED] Clearing the CheckboxSelectionModel

    Hi,

    Hope you can help me with following:

    Clearing rows from the CheckboxSelectionModel does not seem to work in my scenario.
    1. Press button 1. A grid is filled with one item (ID 1), the item is default checked. The Window is Showed.
    2. Press the Process button. In the DirectEvent is determined how many rows are checked (the MessageBox will display '1').
    3. Close the Window.
    4. Press button 2. The grid is filled with a new item (ID 2), the CheckboxSelectionModel is again cleared and the grid item is added.
    5. Now press the Process button. I would expect that only 1 item is available in the SelectionModel (ID 2). But the SelectionModel contains also the first item (ID 1). How is this possible?



    I use Ext.NET version: 2.2.0.29802

    Thanks,
    Sander


    <%@ Page Language="C#" %>
    
    
    <script runat="server">
        
        public void OnSelectId1ButtonClick(object sender, DirectEventArgs e)
        {
            dataStore.DataSource = new object[] { new { Id = 1, Message = "ID 1" } };
            dataStore.DataBind();
            
            CheckboxSelectionModel sm = SelectionGrid.SelectionModel.Primary as CheckboxSelectionModel;
            sm.ClearSelection();
            sm.SelectedRows.Clear();
            sm.SelectedRows.Add(new SelectedRow("1"));
            sm.UpdateSelection();
            
            SelectWindow.Show();
        }
    
    
        public void OnSelectId2ButtonClick(object sender, DirectEventArgs e)
        {
            dataStore.DataSource = new object[] { new { Id = 2, Message = "ID 2" } };
            dataStore.DataBind();
            
            CheckboxSelectionModel sm = SelectionGrid.SelectionModel.Primary as CheckboxSelectionModel;
            sm.ClearSelection();
            sm.SelectedRows.Clear();
            sm.SelectedRows.Add(new SelectedRow("2"));
            sm.UpdateSelection();
            
            SelectWindow.Show();
        }
    
    
        public void OnProcessButtonClick(object sender, DirectEventArgs e)
        {
            CheckboxSelectionModel sm = SelectionGrid.SelectionModel.Primary as CheckboxSelectionModel;
            Ext.Net.X.Msg.Show(new MessageBoxConfig
            {
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.ERROR,
                Title = "Checked items count",
                Message = sm.SelectedRows.Count.ToString()
            });
        }
    
    
    </script>
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
    
            <ext:Button ID="SelectId1Button" runat="server"
                Text="Select ID 1">
                <DirectEvents>
                    <Click OnEvent="OnSelectId1ButtonClick" />
                </DirectEvents>
            </ext:Button>
    
    
            <ext:Button ID="SelectId2Button" runat="server"
                Text="Select ID 2">
                <DirectEvents>
                    <Click OnEvent="OnSelectId2ButtonClick" />
                </DirectEvents>
            </ext:Button>
    
    
            <ext:Window ID="SelectWindow" runat="server"
                Width="250"
                Height="250"
                Title="Select"
                Hidden="true"
                CloseAction="Hide"
                Layout="FitLayout">
                <Buttons>
                    <ext:Button ID="ProcessButton" runat="server"
                        Text="Process">
                        <DirectEvents>
                            <Click OnEvent="OnProcessButtonClick" />
                        </DirectEvents>
                    </ext:Button>
                </Buttons>
                <Items>
                    <ext:GridPanel ID="SelectionGrid" runat="server">
                        <Store>
                            <ext:Store ID="dataStore" runat="server">
                                <Model>
                                    <ext:Model ID="Model2" runat="server" IDProperty="Id">
                                        <Fields>
                                            <ext:ModelField Name="Id" Type="Int" />
                                            <ext:ModelField Name="Message" />
                                        </Fields>
                                    </ext:Model>
                                </Model>
                            </ext:Store>
                        </Store>
                        <ColumnModel ID="ColumnModel1" runat="server">
                            <Columns>
                                <ext:Column ID="Column1" runat="server" DataIndex="Id" Text="Id" />
                                <ext:Column ID="Column2" runat="server" DataIndex="Message" Text="Message" Width="120" />
                            </Columns>
                        </ColumnModel>
                        <SelectionModel>
                            <ext:CheckboxSelectionModel ID="ExportRowSelectionModel" runat="server" />
                        </SelectionModel>
                    </ext:GridPanel>
                </Items>
            </ext:Window>
        </form>
    </body>
    </html>
    Last edited by Daniil; Mar 14, 2013 at 12:51 PM. Reason: [CLOSED]
  2. #2
    Hi Sander,

    Thank you for the report. We are investigating a fix.
  3. #3
    Well, it is SelectionMemory plugin's behavior.

    It is mostly usable for paging.

    You can turn it off setting this for the GridPanel.
    SelectionMemory="false"
    Or clear memory manually if needed.
    this.SelectionGrid.Call("clearMemory");
    You can call it near:
    sm.ClearSelection();
  4. #4
    Problem solved, thanks!

Similar Threads

  1. Combo is not clearing
    By Nagaraju in forum 1.x Help
    Replies: 3
    Last Post: May 20, 2011, 10:27 AM
  2. [CLOSED] Panel AutoLoad Url clearing
    By kenanhancer in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 11, 2011, 9:00 AM
  3. [CLOSED] clearing selections in grid
    By alexp in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 07, 2009, 9:08 AM
  4. Clearing out a GridPanel
    By principal_X in forum 1.x Help
    Replies: 0
    Last Post: Feb 05, 2009, 7:32 PM
  5. Replies: 7
    Last Post: Dec 11, 2008, 7:24 AM

Posting Permissions