PDA

View Full Version : [CLOSED] Toggle Panel substr error



softmachine2011
Sep 21, 2012, 7:17 AM
Hi,

With new revision I found a problem with a custom case to expand or collapse panel.

This is my test case:

TEST CASE

ASPX


<!DOCTYPE html>
<html>
<head runat="server">
<title>GridPanel with FitLayout - Ext.NET Examples</title>
<script type="text/javascript">
var isPanelWorking = false;
var onToggle = function () {
if (isPanelWorking == false) {
isPanelWorking = true;
var wasCollapsed = pnlAsigMasiva.collapsed != false;

if (wasCollapsed)
pnlAsigMasiva.expand();
else
pnlAsigMasiva.collapse("bottom", true);

isPanelWorking = false;
}
}
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:Viewport runat="server" Layout="FitLayout" Border="false">
<Items>
<ext:Panel runat="server" Border="false" Layout="BorderLayout">
<Items>
<ext:Panel runat="server" Border="false" Region="Center">
<Items>
<ext:Button runat="server" Text="Expand/Collapse">
<Listeners>
<Click Fn="onToggle" />
</Listeners>
</ext:Button>
</Items>
</ext:Panel>
<ext:Panel ID="pnlAsigMasiva" runat="server" Layout="FitLayout" Collapsed="true"
Collapsible="true" Height="300" Region="South" Title="Collapsed Panel"
Split="true" Hidden="false">
<Items>
<ext:Label runat="server" Text="My Text in Panel" />
</Items>
<Listeners>
<BeforeCollapse Fn="onToggle" />
<BeforeExpand Fn="onToggle" />
</Listeners>
</ext:Panel>
</Items>
</ext:Panel>
</Items>
</ext:Viewport>
</form>
</body>
</html>


As I see my buttom works well as expected but pressing panel expand button now internally fires toggleButton function and when this delegates to expand method without parameter internally pass a true in animate parameter and crashes when it does a substr of this boolean. I don't know if this is the error.

Thanks

Daniil
Sep 21, 2012, 10:17 AM
Hi,

I think it is not well designed to call the collapse and expand methods within the BeforeCollapse and BeforeExpand listeners.

Though, it should function well, if you would prevent a default action returning false from the listener.

Example

var onToggle = function () {
if (isPanelWorking == false) {
/* you code here */

return false;
}
};

softmachine2011
Sep 21, 2012, 10:26 AM
Yes, you are right, with return false now works like in the past.

Thanks