Jul 04, 2014, 2:03 AM
[CLOSED] Radio Group does not work if bound data is boolean
Hi, I have a simple control with three radio button groups and a text box (see below). I have a data source that has four fields one of which is called 'notBool' and it contains a true/false string and another is called isBool and it contains, yes you guessed it, true/false as boolean values. The other two fields are an integer which is linked to an isNumber radio group and a text field which is just there to check its working.
I have set the Dataindex of each radio button to its respective field name and I am loading data through a form.panel using the loadRecord() function.
The 'isNumber' radio group works correctly. I can set the radio button's InputValue to any number and the buttons follow the isNumber field value.
The 'notBool' radio group's buttons have an InputValue of 'true' or 'false' and these are linked to the 'notBool' string field and they work perfectly.
The problem occurs with the 'isBool' radio group which also has it's radio buttons InputValue set to 'true' or 'false' and linked to the 'isBool' boolean field and they do not work.
I have tried different capitalizations like 'True'/'False' and 'TRUE'/'FALSE' and even 1/0 and I am yet to find a combination that works. I have tried using 'setValue()' on the Radio group rather than through the form and this doesn't work.
So my obvious question is 'what am I doing wrong?' and my alternative question is 'what is wrong with Ext.net 2 that this is failing?' When I look at the generated javascript and compare it with that on the Sencha site for the radio group example it looks fine apart from the addition of the DataIndex field.
I have set the Dataindex of each radio button to its respective field name and I am loading data through a form.panel using the loadRecord() function.
The 'isNumber' radio group works correctly. I can set the radio button's InputValue to any number and the buttons follow the isNumber field value.
The 'notBool' radio group's buttons have an InputValue of 'true' or 'false' and these are linked to the 'notBool' string field and they work perfectly.
The problem occurs with the 'isBool' radio group which also has it's radio buttons InputValue set to 'true' or 'false' and linked to the 'isBool' boolean field and they do not work.
I have tried different capitalizations like 'True'/'False' and 'TRUE'/'FALSE' and even 1/0 and I am yet to find a combination that works. I have tried using 'setValue()' on the Radio group rather than through the form and this doesn't work.
So my obvious question is 'what am I doing wrong?' and my alternative question is 'what is wrong with Ext.net 2 that this is failing?' When I look at the generated javascript and compare it with that on the Sencha site for the radio group example it looks fine apart from the addition of the DataIndex field.
<%@ Control Language="VB" ClassName="Test" CodeFile="Test.ascx.vb" Inherits="Test" ClientIDMode="Static" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<ext:ResourceManager runat="server" Theme="Gray" RenderScripts="Embedded" ScriptMode="Debug" SourceFormatting="true" />
<ext:Store runat="server" ID="TestStore" AutoDataBind="true" AutoLoad="true" AutoSync="true">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="notBool" />
<ext:ModelField Name="isBool" Type="Boolean" />
<ext:ModelField Name="TextVal" />
<ext:ModelField Name="isNumber" Type="Int" />
</Fields>
</ext:Model>
</Model>
<Listeners>
<Load Handler="#{frmTest}.getForm().loadRecord(records[0]);
#{isBool}.setValue(records[0].data);" />
</Listeners>
</ext:Store>
<ext:FormPanel runat="server" ID="frmTest" Frame="true" Width="600" Height="400">
<Items>
<ext:RadioGroup runat="server" ID="notBool" GroupName="notBool" FieldLabel="Not Boolean" ColumnsNumber="2">
<Items>
<ext:Radio runat="server" DataIndex="notBool" InputValue="true" BoxLabel="Yes" />
<ext:Radio runat="server" DataIndex="notBool" InputValue="false" BoxLabel="No" />
</Items>
</ext:RadioGroup>
<ext:RadioGroup runat="server" ID="isBool" GroupName="isBool" FieldLabel="Is Boolean" ColumnsNumber="2">
<Items>
<ext:Radio runat="server" BoxLabel="Yes" DataIndex="isBool" InputValue="true" />
<ext:Radio runat="server" BoxLabel="No" DataIndex="isBool" InputValue="false" />
</Items>
</ext:RadioGroup>
<ext:RadioGroup runat="server" ID="isNumber" GroupName="isNumber" FieldLabel="Is Number" ColumnsNumber="2">
<Items>
<ext:Radio runat="server" DataIndex="isNumber" InputValue="1" BoxLabel="Yes" />
<ext:Radio runat="server" DataIndex="isNumber" InputValue="2" BoxLabel="No" />
</Items>
</ext:RadioGroup>
<ext:TextField runat="server" ID="TextVal" DataIndex="TextVal" FieldLabel="Text" />
</Items>
</ext:FormPanel>
<script runat="server">
Imports Microsoft.VisualBasic
Public Class Test
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim BoolTest As New List(Of TestBool)
BoolTest.Add(New TestBool With {.notBool = "true", .isBool = True, .TextVal = "Yes it did", .isNumber = 1})
Me.TestStore.DataSource = BoolTest
Me.TestStore.DataBind()
End Sub
End Class
Class TestBool
Public Property notBool As String
Public Property isBool As Boolean
Public Property TextVal As String
Public Property isNumber As Integer
End Class
</script>
Last edited by Daniil; Jul 15, 2014 at 1:03 PM.
Reason: [CLOSED]