PDA

View Full Version : [CLOSED] [#73] GridPanel's SelectionChange is being raised when deselecting all with supressEvent set to true



RCN
Dec 05, 2012, 7:46 PM
Run the following example, select one element and the press Click Me to Deselect ALL button. The SelectionChange is being raised when deselectAll is invoked. Note that it was invoked with suppressEvent parameter set to true, so i think that SelectionChange should not be raised.

deselectAll method reference:
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.selection.Model-method-deselectAll

1 - View


<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<script type="text/javascript">
var deselectAll = function () {
App.GridPanel1.selModel.deselectAll(true);
}
</script>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Button Text="Click Me to Deselect ALL" runat="server">
<Listeners>
<Click Handler="deselectAll();" />
</Listeners>
</ext:Button>
<ext:GridPanel ID="GridPanel1" runat="server" Title="Records">
<Store>
<ext:Store runat="server" ID="Store2">
<Proxy>
<ext:AjaxProxy Url="/Example/LoadFakeRecords/">
<ActionMethods Read="POST" />
<Reader>
<ext:JsonReader Root="data" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model ID="Model2" runat="server">
<Fields>
<ext:ModelField Name="Name" Type="String" />
</Fields>
</ext:Model>
</Model>
<Sorters>
<ext:DataSorter Property="Common" Direction="ASC" />
</Sorters>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ID="Column3" runat="server" Text="Name" DataIndex="Name" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel runat="server" />
</SelectionModel>
<Listeners>
<SelectionChange Handler="alert('Selection Change');" />
</Listeners>
</ext:GridPanel>
</body>
</html>


2 - Controller


public class ExampleController : System.Web.Mvc.Controller
{
public ActionResult Index()
{
return View();
}

public StoreResult LoadFakeRecords()
{

List<Person> lst = new List<Person>();

for (int index = 0; index < 15; index++)
{
lst.Add(new Person
{
Name = "Name" + index
});
}

return new StoreResult(lst, lst.Count());
}
}


3 - Utility


public class Person
{
public string Name { get; set; }
}


It's possible to overcome this issue by adding the following condition on line 14:


&& !suppressEvent




Ext.override(Ext.selection.Model, {
deselectAll: function (suppressEvent) {
var me = this,
selections = me.getSelection(),
i = 0,
len = selections.length,
start = me.getSelection().length;

me.bulkChange = true;
for (; i < len; i++) {
me.doDeselect(selections[i], suppressEvent);
}
delete me.bulkChange;
me.maybeFireSelectionChange(me.getSelection().leng th !== start && !suppressEvent);
}
});


I would like to know if this is a bug or if i need to register to Select and Deselect listeners

Thanks in advance

RCN
Dec 05, 2012, 8:02 PM
Please, take a look on ExtJs Forum regarding this issue:

http://www.sencha.com/forum/showthread.php?136629-ExtJS-4.1.0-suppressEvent-is-not-respected-in-CheckboxModel.onSelectChange&p=880943&viewfull=1#post880943

Daniil
Dec 06, 2012, 5:48 AM
Hi Raphael,

Thank you for the report!

I think it is a bug.

I reported it to Sencha.
http://www.sencha.com/forum/showthread.php?250836

Lets wait what they will answer.

RCN
Dec 06, 2012, 11:23 AM
Thank you Daniil, please keep me posted about any updated regarding this issue

Daniil
Dec 06, 2012, 4:24 PM
Sencha opened a bug ticket.

We also opened an Issue to track this defect, see:
https://github.com/extnet/Ext.NET/issues/73

RCN
Jan 21, 2015, 2:46 PM
I confirm that this issue has been fixed in the SVN trunk. It will go to v3.1.0 beta release.