View Full Version : 2 questions with geting at information outside and inside of the data store root?

15 Jun 2010, 8:25 AM
We have a JSON response with alot of information.
i.e. Title, DateUpdated, rows.

rows is what the datastore has set to the root [root: 'rows']

The question is how can I through the datastore get at the title?

Q#1. Do I have to create some variable and make an ajax call to populate it and then manually load the datastore with the variable.rows data?

Q#2. if rows contains [id, title, url] but I am only displaying title, how can i have the onselect listener get the url value?

15 Jun 2010, 8:55 AM
check the doc for the Row selection Model. the 3rd param returned for that event is Ext.data.Record...Use console.log(r) and firebug should show you the object attributes which you want to access as long as that field was specified in your Data Store field list and your column model has it defined (hidden:true).

Edit: Sorry, I assumed based on question 2 that you are trying to access a value of hidden cell within a grid. If that's not the case, you'll need a different approach. What type of component/element are you listening for the event on? Example code would be helpful.

15 Jun 2010, 8:55 AM
There are lots of ways of doing this. Each level provides more ease of use.

Non-Sencha, ye old javascript: XHR.
Basic Sencha: Ext.Ajax.request(), no data management.
Store, JsonStore, data management.

You can go as far as providing the metaData (note the Capital D) to your JsonReader (only available in JsonReader) of your store. See the API docs for this (http://www.sencha.com/deploy/dev/docs/?class=Ext.data.JsonReader).

The root only provides the variable within the response that it will find the data. The only data that will be found is the fields that you specify. You can always access the store's data. Let's say you have a grid. To get the store, you need to call... this (http://www.sencha.com/deploy/dev/docs/?class=Ext.grid.GridPanel&member=getStore)
To get to the row, you need to call... this (http://www.sencha.com/deploy/dev/docs/?class=Ext.data.Store&member=getAt) To call the individual rows, you can call... this (http://www.sencha.com/deploy/dev/docs/?class=Ext.data.Record&member=get)

Assuming that you are viewing the data via a GridPanel, even though didn't display the value in the grid, you still have access to the grid's store.

Did you mean "select" listener?

15 Jun 2010, 11:10 AM
JsonReader (http://www.sencha.com/deploy/dev/docs/?class=Ext.data.JsonReader) has a property jsonData :

After any data loads, the raw JSON data is available for further custom processing. If no data is loaded or there is a load exception this property will be undefined.

Q#1. no. after data loads, the raw JSON is available... you may use a load listener on the store to do something after the data loads.