-
1 Feb 2012 9:46 AM #1
Answered: get fiels's content
Answered: get fiels's content
Hi,
Using a navigation view, i have added fields to a view and a (submit button) :
The button well work, but i wanna know the more efficient way to get the value of each field.Code:{ title: 'LiveSum', layout: 'vbox', padding: 10, items: [ // ----- Live profile's name ----- { xtype: 'textfield', id: 'liveprofilename', name: 'liveprofilename', label: _strings_live_name[dmngConfig.deviceLanguageID], labelAlign: 'left', labelWidth: '45%', value: localStorage['liveprofileName'], maxLength: 10, allowBlank: false, readOnly: true }, // ----- Autorecord ----- { xtype: 'togglefield', id: 'autorecord', name: 'autorecord', label: _strings_live_autorecord[dmngConfig.deviceLanguageID], labelAlign: 'left', labelWidth: '45%', value: false, }, // ----- Video input ----- /*{ xtype: 'selectfield', id: 'videoinput', name: 'videoinput', label: _strings_live_videoinput[dmngConfig.deviceLanguageID], labelAlign: 'left', labelWidth: '45%', valueField: 'id', displayField: 'name', store: VideoInputStore },*/ // ----- Studio ----- { xtype: 'selectfield', id: 'studio', name: 'studio', label: _strings_live_studio[dmngConfig.deviceLanguageID], labelAlign: 'left', labelWidth: '45%', valueField: 'id', displayField: 'name', store: StudioStore }, // ----- Live channel ----- { xtype: 'numberfield', id: 'channel', name: 'channel', label: _strings_live_channel[dmngConfig.deviceLanguageID], labelAlign: 'left', labelWidth: '45%', value: '12', maxLength: 5, allowBlank: false, readOnly: true }, // ----- Start live button ----- { xtype: 'button', text: _strings_live_start[dmngConfig.deviceLanguageID], handler: function() { // read the parameters // send the the startLive using a JsonRPC call... // Switch to the live run view liveview.push(3); } }
Indeed, i want to valid the form by my own before to do something else.
Thanks you for your reply
Regards
-
Best Answer Posted by Thierryg
Hi,
No they are not.
So the only (best) way if to get the object using their id right as the dom function getelementbyid(). In sencha touch 2 i have used the getCmp() function
val myfield = listview.getCmp('idfield').getvalue();
is it correct ?
Thanks in advance.
Regards.
-
1 Feb 2012 9:59 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,117
- Vote Rating
- 453
- Answers
- 3160
If the fields are in a form you can use the getValues method to get all the values.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
1 Feb 2012 12:02 PM #3
Hi,
No they are not.
So the only (best) way if to get the object using their id right as the dom function getelementbyid(). In sencha touch 2 i have used the getCmp() function
val myfield = listview.getCmp('idfield').getvalue();
is it correct ?
Thanks in advance.
Regards.
-
1 Feb 2012 1:19 PM #4
Correct. It is also the most performant way.
Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
2 Feb 2012 6:16 AM #5Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,117
- Vote Rating
- 453
- Answers
- 3160
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
2 Feb 2012 6:26 AM #6
Hi,
Okay, if this is the best way, what do you suggest to do, in order to solve my need ?
I agree, id are native to the dom and they are interesting if we are using direct dom access.
Sencha Touch #2, is a framework above the dom and define some objects.
Futhermore, if make introspection on objects, i have seen that sometimes some objects can hide others.
I have to be careful if i start to work with ids.
Thanks i advance of your reply
Regards
-
2 Feb 2012 9:51 AM #7
Sure, but again, it isn't the most performant way; and on mobile devices we are seeing this more and more, especially on Android. While ComponentQuery is amazing and very flexible, you should only use it on specific cases where you cannot use id.
All you have to remember is that id's are unique. You can only use them once; it's as simple as that. They are not connected to the DOM in a way that the developer has to worry.Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.


Reply With Quote