VIEW CODE:
[code="js"]
console.log(Ext.create('PersonMani.store.MenuNodes').getCount()
console.log(Ext.create('PersonMani.store.MenuNodes').data.length);
打印结果都为 0,如何才能访问到MenuNodes的长度与元素?
Ext.define('PersonMani.view.LeftMenuTree', {
extend: 'Ext.panel.Panel',
alias: 'widget.leftmenutree',
title: 'Menu',
id:'tpanel',
....
iconCls : 'icon-accordion',
layout: {
type: 'accordion'
},
initComponent: function() {
var me = this;
....
me.callParent(arguments);
}
});
[/code]
STORE CODE:
[code="js"]
Ext.define('PersonMani.store.MenuNodes', {
extend: 'Ext.data.Store',
requires: 'PersonMani.model.MenuNode',
model: 'PersonMani.model.MenuNode',
autoLoad: true,
proxy: {
type: 'ajax',
api: {
read : 'menunode/view.action'
},
reader: {
type: 'json',
root: 'data',
successProperty: 'success',
},
writer: {
type: 'json',
writeAllFields: true,
encode: false,
root: 'data'
},
listeners: {
exception: function(proxy, response, operation){
Ext.MessageBox.show({
title: 'REMOTE EXCEPTION',
msg: operation.getError(),
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
}
}
}
});
[/code]