View Full Version : [CLOSED] SelectionModel returning last selected record in code behind.

Jun 26, 2013, 8:08 PM
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?


<ext:Viewport runat="server" ID="uxViewPort" Layout="BorderLayout" IDMode="Explicit" IsDynamic="False" Namespace="App" RenderXType="True">
<ext:GridPanel ID="uxSecurityRoleGridPanel"
Title="System Roles"
Margins="5 5 5 5" >
<ext:Toolbar runat="server">
<ext:Button runat="server" Text="Add Role" Icon="UserAdd">
<Click OnEvent="deAddRole"></Click>
<ext:ToolbarSeparator runat="server">
<ext:Button runat="server" Text="Edit Role" Icon="UserEdit"></ext:Button>
<ext:ToolbarSeparator ID="ToolbarSeparator1" runat="server">
<ext:Button runat="server" Text="Delete Role" Icon="UserDelete">
<Click OnEvent="deDeleteRole"><Confirmation ConfirmRequest="true" Message="Are you sure you want to delete this role?"></Confirmation>
runat="server" OnReadData="deSecurityRoleRefresh">
<ext:Model ID="uxSecurityRoleModel" runat="server" IDProperty="ROLE_ID">
<ext:ModelField Name="ROLE_ID" Type="Int" />
<ext:ModelField Name="NAME" Type="String" />
<ext:ModelField Name="DESCRIPTION" Type="String"/>
<ColumnModel ID="uxSecurityRoleColumns" runat="server">
<ext:Column ID="cName" runat="server" DataIndex="NAME" Text="Name" Flex="1" />
<ext:Column ID="cDescription" runat="server" DataIndex="DESCRIPTION" Text="Description" Flex="1" />
<ext:GridFilters runat="server" ID="uxSecurityRoleGridFilters" Local="true">
<ext:StringFilter DataIndex="NAME" />
<ext:StringFilter DataIndex="DESCRIPTION" />
<ext:PagingToolbar ID="uxSecurityRolePaging" runat="server" />
<ext:RowSelectionModel ID="uxSecurityRoleSelectionModel" runat="server" Mode="Single" >


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();


Jun 26, 2013, 8:17 PM
Sorry this works 2 times, fails after the 3rd attempt...

Jun 26, 2013, 9:11 PM
I believe I fixed it by clearing the selection model on delete but shouldn't that happen auto "magically" on a databind?

Jun 27, 2013, 2:05 AM

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: http://examples2.ext.net/#/GridPanel/Selection_Models/Row_Selection/

Jun 27, 2013, 6:49 AM
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.

Jun 27, 2013, 1:56 PM
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.

Jun 28, 2013, 2:40 PM
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!