PDA

View Full Version : [CLOSED] Prevent default action in radio group not working



exe
Nov 16, 2015, 11:28 PM
Hello, why is this not working? (the radio gets selected every time, it shouldn't)



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

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

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
}
}

</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title></title>

<script type="text/javascript">
var change = function (item) {
console.debug(item);
};
</script>

</head>
<body>
<ext:ResourceManager runat="server" />

<ext:RadioGroup runat="server" FieldLabel="Rating" ColumnsNumber="3" AutomaticGrouping="false">
<Items>
<ext:Radio runat="server" Name="rating" InputValue="0" BoxLabel="A" ReadOnly="false" />
<ext:Radio runat="server" Name="rating" InputValue="1" BoxLabel="B" ReadOnly="false" />
<ext:Radio runat="server" Name="rating" InputValue="2" BoxLabel="C" ReadOnly="false" />
</Items>

<Listeners>
<Change Handler="change(item);" PreventDefault="False" StopEvent="True" StopPropagation="True"></Change>
</Listeners>
</ext:RadioGroup>
</body>
</html>

Daniil
Nov 17, 2015, 9:57 AM
Hi @exe,

I think the Change event fires when a Radio's state is already changed and the event is not meant to be able to prevent it.

As far as I can see there is no BeforeChange event in API.

I can suggest this solution.

<ext:Radio ...>
<Listeners>
<AfterRender Handler="this.onBoxClick = Ext.Function.createInterceptor(this.onBoxClick, beforeOnBoxClick);" />
</Listeners>
</ext:Radio>

var beforeOnBoxClick = function (e) {
if (true) { // Prevent condition
return false;
}
};

exe
Nov 17, 2015, 4:06 PM
The workaround is working as expected.

Thanks!