PDA

View Full Version : [CLOSED] Clearing the CheckboxSelectionModel



prost
Mar 13, 2013, 3:26 PM
Hi,

Hope you can help me with following:

Clearing rows from the CheckboxSelectionModel does not seem to work in my scenario.

Press button 1. A grid is filled with one item (ID 1), the item is default checked. The Window is Showed.
Press the Process button. In the DirectEvent is determined how many rows are checked (the MessageBox will display '1').
Close the Window.
Press button 2. The grid is filled with a new item (ID 2), the CheckboxSelectionModel is again cleared and the grid item is added.
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>

Daniil
Mar 13, 2013, 4:10 PM
Hi Sander,

Thank you for the report. We are investigating a fix.

Daniil
Mar 13, 2013, 4:21 PM
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();

prost
Mar 14, 2013, 12:49 PM
Problem solved, thanks!