PDA

View Full Version : Uncaught TypeError: Cannot read property 'getCount' of null



mmor30
12 May 2015, 2:01 AM
This bug usually come out on load of a combo box. The combo box store doesn't seem the reason why this happened.

How can I handle this properly?

Thanks!

jmin91
12 May 2015, 12:59 PM
Could you post some some sample code? There isn't a load event for a combo so I'm going to assume you mean load event of the store. Where are you trying to do a getCount? Need to see some sample code. If you're doing a store.getCount(), it should return a number. If it's null, chances are you're trying to do a getCount on the wrong variable and/or outside the scope where it's loaded.

mmor30
12 May 2015, 9:14 PM
Hi jmin91,

Here is the sample code. I don't use getCount(). It's like, when I click the combo box, the Uncaught TypeError follows.




xtype : 'combobox',
editable: false,
displayField : 'taxCodeCorp',
valueField : 'taxRate',
queryMode: 'remote',
pageSize: 12,
minChars : 2,
listeners : {
afterrender: function(combo){
var taxStore = Ext.create('Ext.data.Store', {
autoLoad: true,
model : 'App.model.master.TaxTable',
proxy : {
type : 'ajax',
url : serverUrl +'taxtable/list?taxTypeId=1',
reader : {
type : 'json',
root : 'list'
}
}
});

if(taxStore){
taxStore.load({
scope: this,
callback: function(records, operation, success) {
combo.bindStore(taxStore);
}
});

var pt = this.getPicker().pagingToolbar;
pt.getComponent('first').hide();
pt.getComponent('last').hide();
App.util.Util.pagingToolbarShort(pt);
}
}
}

jmin91
13 May 2015, 4:28 AM
In your debugger what line number/file does it say the Uncaught TypeError occurs? You should be able to track it down in the stack trace. That should point you in the right direction.

tristan.lee
13 May 2015, 1:18 PM
Can you provide a working example of this as a fiddle (https://fiddle.sencha.com) so I can reproduce your issue?

jdkhamba
16 May 2015, 5:34 PM
Looks like you are trying to load the store and then bind the combo afterrender. In that case queryMode:local should be good enough. That should probably resolve your issue.