Javascript 自动加载面板侦听器ExtJs
我在extjs中有一个带有侦听器代码的视图文件,如下所示:Javascript 自动加载面板侦听器ExtJs,javascript,extjs,extjs4,listener,Javascript,Extjs,Extjs4,Listener,我在extjs中有一个带有侦听器代码的视图文件,如下所示: initComponent: function() { Ext.apply(this, { title : 'Form Order', iconCls : 'orderIcon', width : 850,
initComponent: function() {
Ext.apply(this, {
title : 'Form Order',
iconCls : 'orderIcon',
width : 850,
maxHeight : 600,
x : 200,
y : 50,
resizable : true,
resizeHandles : 's n',
constrainHeader : true,
closable : true,
modal : true,
autoShow : false,
autoScroll : true,
overflow : 'auto',
layout: {
type: 'auto',
align: 'stretch'
},
items: [
this.createPanelMC()
]
});
this.callParent(arguments);
},
createPanelMC: function() {
this.requiredSign = '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>';
var panel = Ext.create('Ext.form.Panel', {
defaultType: 'textfield',
name: 'nodebPanel',
width: '100%',
layout: {
type: 'auto',
align: 'stretch'
},
items: [{
xtype : 'fieldset',
name : 'modlayanan',
title : 'Data Pelanggan',
layout : 'column',
width : '95%',
margin : '10',
items: [{
xtype : 'textfield',
name : 'nomor',
id : 'nomor',
itemId : 'nomor',
fieldLabel : 'PSTN',
emptyText : 'Nomor...',
margin : '10 0 0 0',
width : 350,
labelWidth : 100,
afterLabelTextTpl: this.requiredSign
}, {
xtype : 'textfield',
fieldLabel : 'Speedy',
name : 'speedy',
id : 'speedyVal',
itemId : 'speedyVal',
margin : '10 0 10 20',
width : 350,
labelWidth : 100
}, {
xtype : 'textareafield',
name : 'instaLAddress',
fieldLabel : 'Alamat Instalasi',
emptyText : 'Alamat Instalasi...',
readOnly : true,
labelWidth : 100,
autofocus: true,
//listener
listeners : {
render: function() {
this.getEl().on('mousedown', function(e, t, eOpts) {
var nopstn = Ext.getCmp('nomor').getValue();
var speedy = Ext.getCmp('speedyVal').getValue();
if (nopstn != '' && speedy != '') {
var store = Ext.ComponentQuery.query('#treeProduct')[0].getStore();
console.log(store);
store.load({
params: {
nopstn: nopstn,
speedy: speedy
}
});
}
});
}
}
},
this.createTreePaketExist(),
]
}]
});
return panel;
},
createTreePaketExist: function() {
var storeTree = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'data/newoss_get_paket.php',
actionMethods :{
create: 'POST', read: 'POST', update: 'POST', destroy: 'POST'
}
}
});
var groupProduct = Ext.create('Ext.tree.Panel', {
store : storeTree,
itemId : 'treeProduct',
renderTo : Ext.getBody(),
name : 'treeProduct',
rootVisible : false,
useArrows : true,
layout :'fit',
margin : '0 0 0 0',
autoScroll : true,
height : 150,
width : '93%',
listeners:
{
checkchange: function(node, checked, eOpts){
node.eachChild(function(n) {
node.cascadeBy(function(n){
n.set('checked', checked);
});
});
p = node.parentNode;
var pChildCheckedCount = 0;
p.suspendEvents();
p.eachChild(function(c) {
if (c.get('checked')) pChildCheckedCount++;
p.set('checked', !!pChildCheckedCount);
});
p.resumeEvents();
}
}
});
return groupProduct;
}
侦听器将在createTreePaketExist中显示树面板。问题是。。我想显示树面板的结果,而不点击任何东西,只是显示结果时,面板加载。
在我的代码中,结果将在我将指针放入TextArea字段后显示。它怎么能不点击就显示,面板加载时就显示?有人能帮我吗?谢谢。我想这已经在你之前的报告中得到了回答 这里的问题是,您的存储依赖于用户键入的值,因此在用户完成某些操作之前,您的存储无法加载 因此,除非提供用于加载存储的默认值,否则无法在没有这些值的情况下自动加载存储。如果用户输入新信息,则可以使用不同的数据重新加载存储
如果不知道商店正在使用什么数据、如何根据用户数据过滤数据、他们可以输入或您希望他们输入什么数据,就很难对此提供深入的答案。好的,我明白了。。如果我将函数放入控制器,是否有解决方案@Scriptable如果文本字段不是空的@Scriptable,我可以给监听器一个吗?对不起,我只是遇到了这个注释,把函数放在哪里并不重要,关键是存储数据是无效的,直到它有了来自用户的参数。它实际上不需要是一个函数,你只需要一个存储,你可以在以后过滤它