Sep 24, 2014, 4:26 PM
getSelectionMemory().clearMemory() does not clear SelectedRows if current page has no checked items
On a paged GridPanel using the checkbox selection model, the list of checked items is unreliably unchecked if we try to 'uncheck all items'. This is not possible to trigger if we have a column checkbox like in [url]https://examples2.ext.net/#/GridPanel/Selection_Models/Checkbox_Selection/[/code] but if you use an ordinary button to clear the selection, and click it having items checked on other pages only, although on screen all items are cleared, the column selection model's <i>SelectedRows</i> will keep the selections made even though you try to SelectedRows.Clear() during the 'Clear' button click event.
The code to reproduce this issue is as follows:
multipage_clearAll.aspx
If you click 'clear' on any page that has one or more checked items, the clearing works just fine. The only situation I can't effective clear the 'SelectedRows' list is when trying to clear a page having no currently checked items.
Is there a workaround for this? Am I trying something wrong?
The code to reproduce this issue is as follows:
multipage_clearAll.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="multipage_clearAll.aspx.cs" Inherits="ExtNetPlayground.multipage_clearAll" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager runat="server" />
<ext:DropDownField runat="server" ID="ddfTag" TriggerIcon="SimpleMagnify" Editable="false" MatchFieldWidth="false" Width="600">
<Component>
<ext:GridPanel runat="server" ID="gvTag" Width="600" Height="240" HideHeaders="true" MultiSelect="true">
<TopBar>
<ext:Toolbar runat="server" ID="tbTag">
<Items>
<ext:ToolbarFill runat="server" ID="tbfTag" />
<ext:Button runat="server" ID="btnOk" Icon="Accept" Width="80">
<Listeners>
<Click Handler="App.ddfTag.collapse();" />
<AfterRender Handler="App.btnOk.setText('hai');" />
</Listeners>
</ext:Button>
<ext:Button runat="server" ID="btnClear" Icon="ControlRemoveBlue" Width="80">
<Listeners>
<AfterRender Handler="App.btnClear.setText('clear');" />
</Listeners>
<DirectEvents>
<Click OnEvent="ddfTag_ClearSelection" />
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Store>
<ext:Store ID="stoTag" runat="server" PageSize="4">
<Model>
<ext:Model ID="mdlTag" runat="server" IDProperty="Id">
<Fields>
<ext:ModelField Name="Id" Type="Int" />
<ext:ModelField Name="Tag" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server" ID="cmlTag">
<Columns>
<ext:Column runat="server" ID="coltag2" DataIndex="Tag" Flex="1" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel runat="server" ID="csmTag" Mode="Multi" />
</SelectionModel>
<BottomBar>
<ext:PagingToolbar runat="server" ID="pgnTag" />
</BottomBar>
</ext:GridPanel>
</Component>
<DirectEvents>
<Collapse OnEvent="csmTag_SelectionChange" />
</DirectEvents>
</ext:DropDownField>
</div>
</form>
</body>
</html>
multipage_clearAll.aspx.csusing Ext.Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ExtNetPlayground
{
public class tagType
{
public tagType(int i, string t)
{
Id = i;
Tag = t;
}
public int Id { get; set; }
public string Tag { get; set; }
}
public partial class multipage_clearAll : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
stoTag.DataSource = new List<tagType> {
new tagType(1, "First entry"),
new tagType(2, "Second entry"),
new tagType(3, "Thrird entry"),
new tagType(4, "Fourth entry"),
new tagType(5, "Fifth entry"),
new tagType(6, "Sixth entry"),
new tagType(7, "Seventh entry")
};
if (!X.IsAjaxRequest)
{
btnClear.Listeners.Click.Handler = "Ext.net.Mask.show({ msg: 'Updating controls...', el: gvTag });" +
"App.gvTag.getSelectionMemory().clearMemory(); App.csmTag.deselectAll();";
}
}
protected void ddfTag_ClearSelection(object sender, DirectEventArgs e)
{
gvTag.Element.Unmask();
}
protected void csmTag_SelectionChange(object sender, DirectEventArgs e)
{
var msgA = new MessageBoxConfig();
msgA.Buttons = MessageBox.Button.OK;
msgA.Icon = MessageBox.Icon.INFO;
msgA.Title = "Selection Updated.";
msgA.Message = "You have " + csmTag.SelectedRows.Count() + " items selected now.";
X.Msg.Show(msgA);
}
}
}
To reproduce the error:- Compile and run the above page
- Expand the box and check some items on either the first or second page. Click 'hai' (ok) button.
- It will show a message box telling how many items you checked.
- Now, re-expand the box and move to a page where you selected no entries. Click 'Clear'.
- The items on the other page will show unchecked. Click 'hai'/ok.
- The message box will still say you have the same amount of checked items, although no item is checked on the grid.
If you click 'clear' on any page that has one or more checked items, the clearing works just fine. The only situation I can't effective clear the 'SelectedRows' list is when trying to clear a page having no currently checked items.
Is there a workaround for this? Am I trying something wrong?
Last edited by fabricio.murta; Sep 24, 2014 at 4:42 PM.
Reason: Added 'deselectAll()' to the event.