PDA

View Full Version : addListener in data view not working



seema
23 Dec 2011, 2:43 PM
Hi,
I'm having a data view. I have to reload this data view with another store, on its selectionchange event.
here is my code


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");



var store = Ext.data.StoreManager.lookup('firstGridStore').loadData(filterValues);


var storeSec=Ext.data.StoreManager.lookup('secondGridStore').removeAll();


showFilterWindow();

}

}

}

});



in showFilterWindow() function, a darg and drop window will open. on click of apply button, we have to refresh the data store.
here is the code I have written to refresh data view.


callApplyFilter= function(){


var myparams = { 'pdb': filterObj };



var myReq=Ext.Ajax.request({

url:'/api/filter.json',

params: Ext.encode(myparams),

method: 'POST',

headers: { 'Content-Type': 'application/json; charset=utf-8' },

success: function(resp) {

var respDecode=Ext.decode(resp.responseText);

var filterData = respDecode.pdb.user.filterResults.partnerFilter.column;

Ext.sidebar.partnerFilter.bindStore(new Ext.data.JsonStore({

model: 'filterModel',

data: filterData,

autoLoad: true

}));



}



});



I'm getting an error in the Data view listenser, that "record is null". Assuming the error is due to the listner, I use this code before bindStore


Ext.sidebar.partnerFilter.clearListeners();


Now this error is not comming but I'm not able to add listener in this dataview again. I've used this code to add listener


Ext.sidebar.partnerFilter.addListener('selectionchange',function(dataV,nodes){

var record = dataV.getLastSelected();


var filterValues =record.get("filterValues");


var store = Ext.data.StoreManager.lookup('firstGridStore').loadData(filterValues);


var storeSec=Ext.data.StoreManager.lookup('secondGridStore').removeAll();

globalFilterNode=record.get("id");

showFilterWindow();

}

);



How cound I achieve this
Please suggest. I'm in the mid of crucial development.

Thanks

jay@moduscreate.com
28 Dec 2011, 6:35 AM
First, i say *do not* add to the Ext JS namespace.

jay@moduscreate.com
28 Dec 2011, 6:42 AM
addListener should work, assuming the reference to that class is correct.

Your problem will be your existing listeners will still be registered.