PDA

View Full Version : GetGroupStore string from another store



Zmanring
23 Jun 2011, 11:16 AM
What I am trying to attempt is using an ID from one store I want to access another store to return a string for grouping.




var newOffersStore = new Ext.data.JsonStore({
model: 'offer',
getGroupString : function(record) {
var id = record.get('CategoryId');

alert(categoryMapStore.getAt(id).data.CategoryName);
return categoryMapStore.getAt(id).data.CategoryName;
},
});

What irritates me is that the alert works fine but when it tries to return I get a TypeError: Result of expression 'categoryMapStore.getAt(id)' [null] is not an object.

Any help or direction would be must appreciated. Once I figure this out then I need to find out how to access the store via an ID and not the index.

Zmanring
23 Jun 2011, 12:03 PM
FIXED: Using the findRecord command



var newOffersStore = new Ext.data.JsonStore({
model: 'offer',
getGroupString : function(record) {
//access name from store.
var id = record.get('CategoryId');
return categoryMapStore.findRecord('CategoryId', id).data.CategoryName;
},
});