[CLOSED] SelectionModel returning last selected record in code behind.

  1. #1

    [CLOSED] SelectionModel returning last selected record in code behind.

    Ok simple one guys. I have a gridpanel and selection model and I'm clicking the row and deleting it from the database and then refreshing the datasource of the store. It works the first time after that it shows me the recordID of the last deleted row. Any ideas?

    Markup
        <ext:Viewport runat="server" ID="uxViewPort" Layout="BorderLayout" IDMode="Explicit" IsDynamic="False" Namespace="App" RenderXType="True">
            <Items>
                <ext:GridPanel ID="uxSecurityRoleGridPanel"
                    runat="server"
                    Title="System Roles"
                    Padding="5"
                    Icon="User"
                    Region="Center"
                    Frame="true"
                    Margins="5 5 5 5" >
                    <TopBar>
                        <ext:Toolbar runat="server">
                            <Items>
                                <ext:Button runat="server" Text="Add Role" Icon="UserAdd">
                                    <DirectEvents>
                                        <Click OnEvent="deAddRole"></Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:ToolbarSeparator runat="server">
                                </ext:ToolbarSeparator>
                                <ext:Button runat="server" Text="Edit Role" Icon="UserEdit"></ext:Button>
                                 <ext:ToolbarSeparator ID="ToolbarSeparator1" runat="server">
                                </ext:ToolbarSeparator>
                                <ext:Button runat="server" Text="Delete Role" Icon="UserDelete">
                                     <DirectEvents>
                                        <Click OnEvent="deDeleteRole"><Confirmation ConfirmRequest="true" Message="Are you sure you want to delete this role?"></Confirmation>
                                           </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <Store>
                        <ext:Store
                            ID="uxSecurityRoleStore"
                            runat="server" OnReadData="deSecurityRoleRefresh">
                            <Model>
                                <ext:Model ID="uxSecurityRoleModel" runat="server" IDProperty="ROLE_ID">
                                    <Fields>
                                        <ext:ModelField Name="ROLE_ID" Type="Int" />
                                        <ext:ModelField Name="NAME" Type="String"  />
                                        <ext:ModelField Name="DESCRIPTION"  Type="String"/>
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel ID="uxSecurityRoleColumns" runat="server">
                        <Columns>
                            <ext:Column ID="cName" runat="server" DataIndex="NAME" Text="Name" Flex="1"  />
                            <ext:Column ID="cDescription" runat="server" DataIndex="DESCRIPTION" Text="Description" Flex="1"  />
                        </Columns>
                    </ColumnModel>
                    <Features>
                        <ext:GridFilters runat="server" ID="uxSecurityRoleGridFilters" Local="true">
                            <Filters>
                                <ext:StringFilter DataIndex="NAME" />
                                <ext:StringFilter DataIndex="DESCRIPTION" />
                            </Filters>
                        </ext:GridFilters>
                    </Features>
                    <BottomBar>
                        <ext:PagingToolbar ID="uxSecurityRolePaging" runat="server"  />
                    </BottomBar>
                    <SelectionModel>
                        <ext:RowSelectionModel ID="uxSecurityRoleSelectionModel" runat="server" Mode="Single" >
                        </ext:RowSelectionModel>
                    </SelectionModel>
                </ext:GridPanel>
                
            </Items>
        </ext:Viewport>
    code for delete
    public void deDeleteRole(object sender, DirectEventArgs e)
            {
                RowSelectionModel sm = uxSecurityRoleGridPanel.GetSelectionModel() as RowSelectionModel;
                long ROLE_ID = long.Parse(sm.SelectedRow.RecordID);
                DBI.Data.DataFactory.Security.Roles.DeleteRoleByID(ROLE_ID);
    
                //Refresh the Security Roles View
                uxSecurityRoleStore.DataSource = DBI.Data.DataFactory.Security.Roles.RoleList();
                uxSecurityRoleStore.DataBind();
               
            }
    Last edited by Daniil; Jun 28, 2013 at 2:40 PM. Reason: [CLOSED]
  2. #2
    Sorry this works 2 times, fails after the 3rd attempt...
  3. #3
    I believe I fixed it by clearing the selection model on delete but shouldn't that happen auto "magically" on a databind?
  4. #4
    Hello!

    Quote Originally Posted by ljankowski View Post
    I believe I fixed it by clearing the selection model on delete but shouldn't that happen auto "magically" on a databind?
    We are investigating.

    In my opinion, it is better to send them from the client side: https://examples2.ext.net/#/GridPane...Row_Selection/
  5. #5
    Hi everybody,

    It is because of a GridPanel's SelectionMemory functionality which is enabled by default. It saves even removed records to have a possibility to restore and submit them in, for example, a case with remote paging. In your case you could switch this functionality off by setting up SelectionMemory="false" for the GridPanel.

    I will discuss with the colleagues a possibility to turn off SelectionMemory by default if no paging.
  6. #6
    Thanks, I'm just going to turn it off for now. We don't use any remote paging at this point and it easy enough to turn off and on based on our needs.
  7. #7
    Finally, we considered it a bug. Now, if no paging the removed records after data binding should be eliminated from selection memory. Thank you for the question!

Similar Threads

  1. Replies: 2
    Last Post: May 09, 2013, 6:16 AM
  2. MultiCombo not returning any selected items
    By dtamils in forum 1.x Help
    Replies: 3
    Last Post: Feb 27, 2013, 3:56 AM
  3. Replies: 5
    Last Post: Oct 27, 2011, 7:39 AM
  4. Replies: 0
    Last Post: Apr 29, 2011, 8:37 PM
  5. [CLOSED] Selected Row Value not returning value from RecordID
    By Christopher Istvan in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 01, 2009, 10:21 PM

Posting Permissions