-
3 Nov 2011 8:20 AM #1
Answered: Dumping data from store to panel HTML
Answered: Dumping data from store to panel HTML
What is the best way to take data from a store with a model and output it to a panel?
I have been trying to access the store outside the definition of the panel and save the contents to a variable that could be used within the panel, but I am having no luck. Assuming I know the field to pull out of the store and there is only one record, what is the best way to get that?
-
Best Answer Posted by slemmon
To find a specific record from a store using the value of a know field I use:
That will give me the record itself.Code:var record = store.getAt(store.find('MY_FIELD', 'given_value'))
If then I need a value from that record stored in a variable I can get it using:
If that is a string I can update a panel's body with the panel's update() method:Code:var str = record.get('THE_FIELD_I_AM_INTERESTED_IN')
Does that help?Code:panel.update(str)
-
3 Nov 2011 12:08 PM #2Sencha User
- Join Date
- Dec 2009
- Location
- Enschede, The Netherlands
- Posts
- 327
- Vote Rating
- 11
- Answers
- 16
I have no idea really what you want to achieve precicely.
If your question is related to displaying the record(s) you could take a look at forms, grids and or dataviews.
But it sounds like you need to access an store inside an method of an panel? In that case you do need an reference. Maybe you can pass it at creationtime or you can use the new StoreManager. Maybe if you post some code helping is easier?
-
3 Nov 2011 1:14 PM #3
To find a specific record from a store using the value of a know field I use:
That will give me the record itself.Code:var record = store.getAt(store.find('MY_FIELD', 'given_value'))
If then I need a value from that record stored in a variable I can get it using:
If that is a string I can update a panel's body with the panel's update() method:Code:var str = record.get('THE_FIELD_I_AM_INTERESTED_IN')
Does that help?Code:panel.update(str)


Reply With Quote