PDA

View Full Version : Can we load a external store through dataview listeners??



seema
12 Dec 2011, 7:13 PM
Hi,
There is one scenario. I have a dataview and on clicking on dataview item, I have to reload an external store. This store will further used to populate a grid.
Is this a possible scenario?

my code is like this-



Ext.sidebar.partnerFilter = new Ext.DataView({
autoScroll: true,
store: strData,
tpl: tplData,
autoHeight: false,
height: 265,
multiSelect: false,
itemSelector: 'div.thumb-wrap',
emptyText: 'No data to display',
loadingText: 'Please Wait...',
style: 'border:1px solid #99BBE8;background:#fff;',
listeners: {
selectionchange: {
fn: function(dataV,nodes){
var record = dataV.getLastSelected();
var filterValues =record.get("filterValues");

myData+= "[";
var len=filterValues.length;
for(var i=0;i<len;i++){
myData+="{name :"+filterValues[i].displayName+"},";
}

myData=Ext.myData.substring(0,Ext.myData.length-1);

myData+="]";

firstGridStore.loadData(myData);

}

}

}

});



here is code for store-


var firstGridStore = Ext.create('Ext.data.Store', {
model: 'DataObject',
data: myData
});



Its throwing me an error "this.data.getRange is not a function".

How could I achieve this. Please suggest

tobiu
13 Dec 2011, 3:28 AM
i would use:
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.StoreManager



Ext.create('Ext.data.Store', {
model: 'SomeModel',
storeId: 'myStore'
});

var store = Ext.data.StoreManager.lookup('myStore');


to get a reference to your external store.

also take a look at:
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store-method-loadData

the signature expects an array of records or an array of objects, so no clue why you are trying to manually build a json string. in case you really need the string (which you don't here), you can create your object and then call: Ext.JSON.encode();

seema
13 Dec 2011, 11:51 AM
Hi,
First of all Thanks a lot for quick response. I really appreciate that.

Its working now.

Thanks