-
31 May 2012 11:53 AM #1
Answered: how to get values from a selected item into a Ext.List....
Answered: how to get values from a selected item into a Ext.List....
Hi,
i have a Ext.List with data inside. very simple. is just for a test for now.
so when i select an item of my list i want to retreive values from it.
all i do is to get my component
var icoList = Ext.getCmp('iconlist'); then the method getSelection();
icoList.getSelection(); when i do that in the console, i get an Object like below. all i want to get is the value of photo: "touch/images/boss.png".
but impossible to get this value.
any help guys please.
thank
Code:[Object
- _data: Object
- id: 5
- photo: "touch/images/boss.png"
- __proto__: Object
- data: Object
- id: 5
- photo: "touch/images/boss.png"
- __proto__: Object
- id: "ext-record-115"
- modified: Object
- raw: Object
- stores: Array[1]
- __proto__: Object
Code:{ xtype: 'list', id: 'iconlist', height: 50, padding: 0, scrollable: 'horizontal', inline: { wrap: false }, data: [ {id: 1, photo: 'touch/images/boss.png'}, {id: 2, photo: 'touch/images/boss.png'}, {id: 3, photo: 'touch/images/boss.png'}, {id: 4, photo: 'touch/images/boss.png'}, {id: 5, photo: 'touch/images/boss.png'}, {id: 6, photo: 'touch/images/boss.png'}, {id: 7, photo: 'touch/images/boss.png'}, {id: 8, photo: 'touch/images/boss.png'}, {id: 9, photo: 'touch/images/boss.png'}, {id: 10, photo: 'touch/images/boss.png'} ], itemTpl: [ '<img src="{photo}">' ] }O.C
Webapps : cirkles.fr/radioz / cirkles.fr/mini / cirkles.fr/obapp /
WebSite: cirkles.fr / cirklewear.fr
- _data: Object
-
Best Answer Posted by Olivierco
thanks,
i found the solution:
the solution is, as sel return an array, I just have to select the object inside the array.
and then access to my value withCode:var icoList = Ext.getCmp('iconlist'), sel = icoList.getSelection(), array = sel[0];
array.data.photo
-
1 Jun 2012 2:23 AM #2
someone?
O.C
Webapps : cirkles.fr/radioz / cirkles.fr/mini / cirkles.fr/obapp /
WebSite: cirkles.fr / cirklewear.fr
-
3 Jun 2012 12:55 PM #3Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3101
getSelection() should return either a record or an array of records. If you want a field value in that record then use the get method on the record passing in the field name you want the value of.
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.
-
3 Jun 2012 1:30 PM #4
thanks,
i found the solution:
the solution is, as sel return an array, I just have to select the object inside the array.
and then access to my value withCode:var icoList = Ext.getCmp('iconlist'), sel = icoList.getSelection(), array = sel[0];
array.data.photoO.C
Webapps : cirkles.fr/radioz / cirkles.fr/mini / cirkles.fr/obapp /
WebSite: cirkles.fr / cirklewear.fr
-
3 Jun 2012 1:56 PM #5Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3101
You should do
Code:array.get('photo')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.
-
3 Jun 2012 2:13 PM #6
i did it,
it works, but why it's better to do array.get('photo') than array.data.photo?O.C
Webapps : cirkles.fr/radioz / cirkles.fr/mini / cirkles.fr/obapp /
WebSite: cirkles.fr / cirklewear.fr
-
3 Jun 2012 4:44 PM #7Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3101
If there is a method available, it's better to use it in general. There may be code in there to return what you expect or a property may be renamed or...
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.


Reply With Quote