PDA

View Full Version : [CLOSED] get checkbox value from form json



redi
Nov 20, 2013, 9:25 AM
Hai..

I have some case ini here. I want to get value from checkbox in my Form Edit, i returned the data Form into json. When i try to get data, if i check the checkbox and in json the checkbox value returned "on" when i uncheck them, the value field of checkbox not shown. I put an attachment image.

Can you show me how to get value from checkbox ? i want to get value if check box is checked then value is 1 if not value is 0

Thanks

Daniil
Nov 20, 2013, 1:03 PM
Hi @redi,

It is how checkboxes are submitted. If checked - there is something in submit, if unchecked - there is nothing.


i want to get value if check box is checked then value is 1 if not value is 0


How do you get the values of the Form?

redi
Nov 21, 2013, 12:58 AM
Hai Daniil,

i used the window, to create a form pop up. This is my aspx windows script :


<ext:Window
ID="winDetails"
runat="server"
Title="Equipment Details"
Icon="Group"
width="400"
height="200"
Modal="true"
Hidden="true"
Layout="FitLayout">
<Items>
<ext:FormPanel
ID="formEdit"
runat="server"
DefaultAnchor="100%"
BodyPadding="5">
<Items>
<ext:TextField ID="EqpId" runat="server" FieldLabel="Equipment ID" ReadOnly="true" />
<ext:TextField ID="EqpModel" runat="server" FieldLabel="Model" ReadOnly="true" />
<ext:Checkbox ID="isActive" runat="server" FieldLabel="Active ? " InputValue="" />
</Items>
</ext:FormPanel>
</Items>
<Buttons>
<ext:Button ID="btnSave" runat="server" Text="Save" Icon="Disk">
<DirectEvents>
<Click OnEvent="btnSave_Click">
<ExtraParams>
<ext:Parameter Name="formParam" Value="Ext.encode(#{formEdit}.getForm().getValues())" Mode="Raw" />
</ExtraParams>
</Click>
</DirectEvents>
<%-- <Listeners>
<Click Handler="alert(Ext.encode(#{formEdit}.getForm().getValues(t rue)));" />
</Listeners>--%>
</ext:Button>
<ext:Button ID="btnCancel" runat="server" Text="Cancel" Icon="Cancel">
<Listeners>
<Click Handler="this.up('window').hide();" />
</Listeners>
</ext:Button>
</Buttons>
</ext:Window>


I get the checkbox value on the btnSave_Click Event, and this is my code behind script :


Public Sub btnSave_Click(ByVal sender As Object, ByVal e As DirectEventArgs) Handles btnSave.Click
Dim jsonString As String
Dim dtInput As New DataSet
'convert to dataset Format JSON
jsonString = "{'TableEqp':[" + e.ExtraParams("formParam") + "]}"
'convert to dataset
dtInput = JsonConvert.DeserializeObject(Of DataSet)(jsonString)

Try
BL.wsUpdateEqpStatus(Me.Session("AuthState"), dtInput)
Store1.DataBind()
Catch ex As Exception
Dim win As New Window
win.ID = "winError"
win.Title = "Error"
win.Icon = Icon.Error
win.Html = ex.Message
win.Render(Me.Form)
End Try


End Sub

Baidaly
Nov 21, 2013, 1:43 AM
Hello!

Try to use getValues with different properties: http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.form.Basic-method-getValues


<ext:Parameter Name="formParam" Value="Ext.encode(#{formEdit}.getForm().getValues(false, false, false, true))" Mode="Raw" />

redi
Nov 21, 2013, 2:30 AM
Hai @Baidaly

i try your suggestion and that's working... :)

thanks for your question @Daniil and @Baidaly. :)

please mark this thread as [CLOSED]