gpt4 book ai didi

class - ExtJs Button 'click' 监听器去类方法

转载 作者:行者123 更新时间:2023-12-02 03:29:17 24 4
gpt4 key购买 nike

给定这个类代码:

///
/// FORM tBasicFrm
///
Ext.define('tBasicBrwFrm',{ extend: 'Ext.panel.Panel'
,id: 'tBasicBrwFrm'
,layout: 'fit'

///
/// CUSTOM PROPERTIES
///
,nOpcion: 0
,lVRet: false
,oParent: null
,oModel: null
,oStore: null
,oGrid: null
,oRecord: null
,oActividad: null

///
/// EVENTS
///
,listeners:{
destroy: function(){
if( this.oStore != null ){
this.oStore.destroy();
}

if( this.oModel != null ){
this.oModel.destroy();
}

if( this.oGrid != null ){
this.oGrid.destroy();
}

if( this.oRecord != null ){
this.oRecord.destroy();
}

if( this.oActividad != null ){
this.oActividad = null;
}

if( this.oParent != null && this.oParent != 'undefined' && Ext.getClass(this.oParent).superclass.self.getName() === 'tBasicFrm'){
if(!this.oParent.isVisible()){
this.oParent.show();
}
}
}
,render: function(){
if(this.oParent != null && this.oParent != 'undefined' && Ext.getClass(this.oParent).superclass.self.getName() === 'tBasicFrm' ){
this.oParent.hide();
}
}
}

///
/// METHODS
///
,cargaActividad: function(){
var oFecha = new Date();
var oHora = new Date();
var nDia = oFecha.getDate();
var nMes = oFecha.getMonth() + 1;
var nAnyo = oFecha.getFullYear();

if( nDia < 10 ){
nDia = '0' + nDia;
}

if( nMes < 10 ){
nMes = '0' + nMes;
}

oFecha = nDia+'/'+nMes+'/'+nAnyo;
oHora = oHora.getHours() + ':' + oHora.getMinutes() + ':' + oHora.getSeconds();

this.oActividad = {
cAlias: ""
,cTipo: ""
,cEstado: ""
,dFecha: oFecha
,cHoraIni: oHora
,cCodigo: ""
,cNumDoc: ""
,cTipoDoc: ""
,cImporte: ""
,cFPago: ""
,cEstado: ""
,cObserva: ""
,cImpresa: ""
}
}
,grabaActividad: function(){

}
,Cerrar: function(){

}
,Insertar: function(){

}
,Modificar: function(){

}
,Eliminar: function(){

}
,Consultar: function(){

}
,Imprimir: function(){

}
,Filtrar: function(){

}

///
/// CONTROLS
///
,dockedItems: [
{
xtype: 'toolbar',
dock: 'top',autoScroll: true,
layout: {
type: 'hbox',
align: 'middle'
},
items: [
{
xtype: 'button',
text: 'Cerrar',
width: 120,
icon: 'img/16x16/Salir16.png',
iconAlign: 'left',
listeners: {
click: 'Cerrar'
}
},
{
xtype: 'button',
text: 'Agregar',
width: 120,
icon: 'img/16x16/Añadir16.png',
iconAlign: 'left',
listeners: {
click: 'Insertar'
}
},
{
xtype: 'button',
text: 'Modificar',
width: 120,
icon: 'img/16x16/Editar16.png',
iconAlign: 'left',
listeners: {
click: 'Modificar'
}
},
{
xtype: 'button',
text: 'Consultar',
width: 120,
icon: 'img/16x16/Consultar16.png',
iconAlign: 'left',
listeners: {
click: 'Consultar'
}
},
{
xtype: 'button',
text: 'Eliminar',
width: 120,
icon: 'img/16x16/Eliminar16.png',
iconAlign: 'left',
listeners: {
click: 'Eliminar'
}
}
]
}
]
});

我找不到配置按钮“Cerrar”监听器以转到类方法“Cerrar”的方法。

我尝试了所有的范围,但没有成功。

谁能帮帮我?

最佳答案

我一直在研究这段代码,并设法让按钮单击处理程序使用下面的监听器代码调用正确的函数,但感觉不太对,通常你可以确定按钮的范围 this 传递父组件的范围,但它似乎对我不起作用。

我会继续研究 scope 方法,但与此同时,您应该能够使用这两种方法中的任何一种:

// method 1
xtype: 'button',
...
listeners: {
click: function() { this.up('panel').Cerrar(); }
}

// method 2
xtype: 'button',
...
listeners: {
click: function() { this.ownerCt.ownerCt.Cerrar(); }
}

关于class - ExtJs Button 'click' 监听器去类方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28109177/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com