PDA

View Full Version : [CLOSED] Multicombo deselect all problem



CarWise
Sep 16, 2013, 12:46 PM
Hi,

Can you tell me what's wrong with this code. I would like to deselect all selected items when unchecking the first item. But it's not working:



<%@ Page Language="C#" %>


<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>


<!DOCTYPE html>


<html>
<head id="Head1" runat="server">
<title>MultiCombo</title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:MultiCombo ID="MultiCombo1" runat="server" Width="260">
<Items>
<ext:ListItem Text="Select All" Value="0" />
<ext:ListItem Text="Item 1" Value="1" />
<ext:ListItem Text="Item 2" Value="2" />
<ext:ListItem Text="Item 3" Value="3" />
<ext:ListItem Text="Item 4" Value="4" />
<ext:ListItem Text="Item 5" Value="5" />
</Items>
<Listeners>
<Select Handler="if (index==0) #{MultiCombo1}.selectAll();"/>
<BeforeDeselect Handler="if (index==0) #{MultiCombo1}.clearValue();"/>
</Listeners>
</ext:MultiCombo>
</form>
</body>
</html>

Martin

Daniil
Sep 16, 2013, 4:16 PM
Hi Martin,

A component instance and an array of selected records are passed to a MultiCombo's Select listener. There is no the index argument. So, a JavaScript error occurs if select an item.

As for deselecting all. The BeforeDeselect listener fires for every deselect items. So, a recursion occurs there.

Though, even if avoid recursion this way:

<BeforeDeselect Handler="if (!this.beforeDeselectLocked) {
if (index === 0) {
this.beforeDeselectLocked = true;
this.clearValue();
this.beforeDeselectLocked = false;
}
}"/>
the clearValue method call clear the value, but doesn't clear selection.

Here is a test case to reproduce.

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>
<html>
<head runat="server">
<title>MultiCombo</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Button runat="server" Text="Clear" Handler="App.MultiCombo1.clearValue();" />

<ext:MultiCombo ID="MultiCombo1" runat="server">
<Items>
<ext:ListItem Text="Item 1" Value="1" />
<ext:ListItem Text="Item 2" Value="2" />
</Items>
</ext:MultiCombo>
</form>
</body>
</html>

Vladimir
Sep 16, 2013, 6:33 PM
clearValue issue is fixed in SVN

CarWise
Sep 17, 2013, 6:44 AM
clearValue issue is fixed in SVN

Works now...using BeforeSelect instead of Select solves the other issue also..

Thanks !

Martin