2017-09-29 4 views
0

나는 Sencha에서 무언가를 바꿀 필요가있다. 나는 두 번째 콤보 박스를 추가해야하는데, 처음에는 비활성화되어 있어야하는데, 괜찮다.하지만 그 다음에는 첫 번째 콤보 박스가 두 번째 콤보 박스를 사용할 수 있도록해야한다. 모두)가 선택되면 매우 간단 해 보입니다. 여기 SENCHA/ext js에서 다른 콤보 박스의 콤보 박스를 활성화하는 방법은 무엇입니까?

코드입니다 :

var formPanel = new Ext.form.FormPanel({ 
    id: 'formanchor-form', 
    title: 'Nuevo Gasto', 
    bodyStyle: 'padding:5px 5px 0', 
    width: 600, 
    defaults: { 
    width: 230 
    }, 
    defaultType: 'textfield', 
    renderTo: 'formulario', 
    frame: true, 
    items: [{ 
    xtype: 'combo', 
    typeAhead: true, 
    name: 'cboGasto', 
    id: 'cboGasto', 
    fieldLabel: 'Gastos', 
    store: storeCbo, 
    displayField: 'gasto', 
    valueField: 'codigo', 
    allowBlank: false, 
    width: 250, 
    mode: 'local', 
    triggerAction: 'all', 
    emptyText: 'SELECCIONE', 
    blankText: 'Debe seleccionar un gasto', 
    forceSelection: true 
    }, { 
    xtype: 'numberfield', 
    fieldLabel: 'Monto', 
    name: 'txtMonto', 
    id: 'txtMonto', 
    maxLength: 7, 
    allowBlank: false, 
    minValue: 100, 
    minText: 'El monto mínimo es 100', 
    maxValue: 9999999, 
    maxLengthText: 'El monto máximo es 9.999.999', 
    blankText: 'El monto es requerido', 
    width: 100 
    }, { 
    xtype: 'combo', 
    typeAhead: true, 
    name: 'CboDeudasReceptor', 
    id: 'CboDeudasReceptor', 
    fieldLabel: 'Receptor', 
    store: storeCboR, 
    displayField: 'receptor', 
    valueField: 'codigo', 
    allowBlank: false, 
    width: 250, 
    mode: 'local', 
    triggerAction: 'all', 
    emptyText: 'SELECCIONE', 
    blankText: 'Debe seleccionar un Receptor', 
    forceSelection: true, 
    disabled: true 
    }], 
    buttons: [{ 
    text: 'Agregar', 
    handler: function() { 
     var mon = Ext.getCmp('txtMonto').getValue(); 
     var gas = Ext.getCmp('cboGasto').getValue(); 
     if (mon.length == 0) { 
     Ext.MessageBox.alert('Monto del Gasto', 'Debe Ingresar un monto para el gasto.'); 
     Ext.getCmp('txtMonto').focus(); 
     return false; 
     } 
     if (gas.length == 0) { 
     Ext.MessageBox.alert('Gasto', 'Debe Seleccionar un gasto.'); 
     Ext.getCmp('cboGasto').focus(); 
     return false; 
     } 
     location.href = 'ingresa_gastos_lib.asp?cboGasto=' + gas + '&txtMontoPesos=' + mon + '&' + params(); 
    } 
    }, { 
    text: 'Volver', 
    handler: function() { 
     location.href = 'datos_deuda.asp?' + params(); 
    } 
    }] 
}); 

UPDATE :

내가 처음 콤보 수신기를 넣으면, 내가 원하는 것처럼 다음 부분 작동하지만, 2 콤보 그냥 드롭 다운을 작동 여전히 장애인처럼 보이고 편집 할 수 없습니다. 이제 문제는 두 번째 콤보 박스를 어떻게 완전하게 작동 시키는가하는 것입니다.

+0

당신이 [바이올린]를 제공 할 수 있습니다 (https://fiddle.sencha.com/) –

답변

1

disabled 필드를 false로 설정하면 해결되지 않습니다. 객체의 속성 값을 변경하는 것이지만 모든 비주얼 스타일은 여전히 ​​존재합니다. 콤보 상자의 setDisabled() 메서드 또는 enable()disabled() 메서드를 사용해야합니다. 그래서 청취자가 다음과 같이한다 :

select: function (combo, record, index) { 
    if (Ext.getCmp('cboGasto').getRawValue()=='RECEPTOR: EMBARGO'){ 
      alert(Ext.getCmp('cboGasto').getRawValue()); 
      Ext.getCmp('CboDeudasReceptor').setDisabled(false); 
      //Or Ext.getCmp('CboDeudasReceptor').enable(); 
     } 
    } 
} 
-1
items:[{ 
    xtype: "combobox", 
    name: "TubeWellId", 
    fieldLabel: "Tubewell", 
    store: tube_well_store, 
    allowBlank: false, 
    displayField: "TubeWellName", 
    valueField: "TubeWellId", 
    queryMode: "local", 
    forceSelection: true, 
    listeners: { 
     select: function (combo) { 
      var getForm = this.up("form").getForm(); 
      if (combo.getValue() === 1) { 
       getForm.findField("TubeWellDistance").setReadOnly(true); 
      } else { 
       getForm.findField("TubeWellDistance").setReadOnly(false); 
      } 
     } 
    } 
}, { 
    xtype: "combobox", 
    name: "TubeWellDistance", 
    fieldLabel: "Tubewell Distance", 
    store: tube_well_store, 
    allowBlank: false, 
    displayField: "DistanceName", 
    valueField: "DistanceId", 
    queryMode: "local", 
    forceSelection: true, 
}] 
관련 문제