Hybrid View
-
13 Nov 2012 8:47 AM #1
Unanswered: Checkbox value "on" on form.loadRecord() and ajaxSubmit config
Unanswered: Checkbox value "on" on form.loadRecord() and ajaxSubmit config
Hi,
Is it bug or just me?
I am loading form data as JSON from server, and values for checkbox'es are string "on", but when form.loadRecord(...) is called it does not make it checked. It works when value is boolean true. The "on" value is get directly from POST. I was looking how to set form to send it's data as JSON and found jsonSubmit config for form panel class, but it is not working. I submit form int this way:
It realy has jsonSubmit config:HTML Code:if (form.isValid()) { form.submit({ clientValidation: true, url: '/backend/ctrl/savePresetData/' + node.data.id, headers: { 'Accept': 'application/json' }, success: function(form, action) { Ext.Msg.alert('Success', 'Succesfully saved!'); }, failure: function(form, action) { switch (action.failureType) { case Ext.form.action.Action.CLIENT_INVALID: Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values'); break; case Ext.form.action.Action.CONNECT_FAILURE: Ext.Msg.alert('Failure', 'Ajax communication failed'); break; case Ext.form.action.Action.SERVER_INVALID: Ext.Msg.alert('Failure', action.result.msg); } } });
HTML Code:Ext.define('AC.view.myForm', { extend: 'Ext.form.Panel', alias: 'widget.mypanel', .... width: '100%', frame: true, border: 0, jsonSubmit: true, // <--- is it good?
-
13 Nov 2012 6:07 PM #2
1. What do your checkboxes' code look like? What are the respective values in the record? When you load record to a form, its checkbox will be checked if the value in record is one of the following:
- true.
- 'true'.
- '1'.
- 1.
- value of checkbox inputValue or 'on' (if there is no inputValue).
2. When you submit the form, a checkbox will be sent with inputValue (if it is checked) or uncheckedValue (if it is unchecked).
-
14 Nov 2012 12:44 AM #3
Thanks, vietits, inputValue and uncheckedValue worked! :-) So many config vars to spot what you need hehe.
On another problem I still can not make my forms to send POST values as JSON. According to Ext.form.Panel documentation, it accepts Ext.form.Basic configs also but it seems does not work when calling .submit() method explicitly
-
15 Nov 2012 1:40 AM #4
I see if autoSync in store is set to true it posts data to server as JSON. How to achieve this when using Ex.Ajax.request() or form.submit()?
-
15 Nov 2012 2:06 AM #5
I find out myself that jsonData instead of params in Ext.Ajax.request() does exactly what I needed :-)
-
15 Nov 2012 2:33 AM #6
To submit form data in json format, you should use Ext.Ajax.request():
Code:if (form.isValid()) { // form.submit({ // clientValidation: true, Ext.Ajax.request({ jsonData: form.getValues(), url: '/backend/ctrl/savePresetData/' + node.data.id, headers: { 'Accept': 'application/json' }, success: function(form, action) { Ext.Msg.alert('Success', 'Succesfully saved!'); }, failure: function(form, action) { switch (action.failureType) { case Ext.form.action.Action.CLIENT_INVALID: Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values'); break; case Ext.form.action.Action.CONNECT_FAILURE: Ext.Msg.alert('Failure', 'Ajax communication failed'); break; case Ext.form.action.Action.SERVER_INVALID: Ext.Msg.alert('Failure', action.result.msg); } } });


Reply With Quote