View Full Version : Problem with JSonStore while using IdProperty

22 Sep 2009, 9:19 PM

I'm using a JsonStore with following configuration:

var xyzStore =new Ext.data.JsonStore({
id: 'store-id',
// store configs
autoDestroy: true,
proxy: new Ext.data.HttpProxy({
url: restUrl,
method: 'GET'
// reader configs
root: 'response',
idProperty: 'recordId',
fields: [ 'recordId', 'name', 'description' ]
My json response looks like the following:

"response": [
"description": null,
"name": "Test",
"recordId": "6039a820-97af-11de-a5c3-551e959117be"
"success": true
I'm expecting that the records that are stored in the "xyzStore" have their "id" set to the value that is coming in "recordId" field in the json response.

I digged further and found the following in JsonReader:

if (s.id || s.idProperty) {
var g = this.getJsonAccessor(s.id || s.idProperty);
this.getId = function(rec) {
var r = g(rec);

return (r === undefined || r === "") ? null : r;

Looks like jsonstore's id is being taken here instead of idProperty and the implementation ends up searching jsonstore's id in the returned jsonobject. Is this expected behavior or a bug? If its an expected behavior, would somebody please let me know how to set returned record's id using such configuration in JsonStore.

and if its a bug, it should have been

var g = this.getJsonAccessor(s.idProperty || 'id'); instead of

var g = this.getJsonAccessor(s.id || s.idProperty); Thanks in advance for any help/pointers

22 Sep 2009, 9:25 PM
If you're assigning an id to a store, you should use storeId, the "id" property on the store was deprecated in 3.0.

22 Sep 2009, 9:38 PM
ahh.. that did the trick. should this be updated in the documentation please?

thanks evant.

22 Sep 2009, 9:46 PM
If you look at the docs you'll see there is no "id" as a property to use on store.

23 Sep 2009, 9:39 AM
Shouldn't the Docs be updated to reflect this? "idProperty" is not listed, and the only reference I could see to it was in the DataProxy class example when overriding the api.

23 Sep 2009, 10:58 AM
evant, point taken. please consider john's thoughts as well...

in addition, "id" seems to be a commonly used property for every component/html element in DOM (it provides unique identity for the element); wouldn't be a better idea to keep this property's purpose consistent across all the components/html standard? please have a thought around this.

thanks for your prompt reply, it saved my morning that moment... :)