Use the value of a radioGroup to perform a query that loads in a comboBox with ExtJs

2

I have a screen that has a radioGroup which only has two options, and depending on which one is selected, a query is made whose returned values are loaded in comboBox . The problem is that the value of radioGroup can not pass it to the Store using the comboBox , I show them the code that is used.

This is used with Extjs. This is the Store code:

var cuentaStore = Ext.create('Ext.data.Store', {
    model : 'catCuentaModel',
    proxy : {
        type : 'ajax',
        url : '../action/cuentas',
        method : 'GET',
        pageParam: false,
        startParam: false,
        limitParam: false,
        noCache: false,
        reader : {
            type : 'json',
            root : 'claveCuenta'
        },
        extraParams : { 
            'tCta' : ''
       }

    }
});

This is the code of the Form:

 MyForm = Ext.create('Ext.form.Panel', {
    title: 'Reporte de Cuentas',
    margin:'5 0 0 300',
    renderTo: 'repcueayb',
    url: urlReporte,
    bodyStyle: 'padding:5px 5px 0',
    //layout: 'vbox',
    frame: true,
    width: 600, //600
    height: 230,
    //layout: 'border',
    standardSubmit: true,
    items: [Txt_FechaIni, Txt_FechaFin,                
      {
        xtype: 'radiogroup',
        id: 'tipoCta',
        fieldLabel: 'Tipo de cuenta',
        width: 300,
        items: [
           {boxLabel: 'A', name: 'tCta', inputValue: 0, checked: true},
           {boxLabel: 'B',   name: 'tCta', inputValue: 1}
        ],
        listeners: {
            scope: this,
            'checked': function() {
                cuentaStore.getProxy().extraParams = {
                    tCta: Ext.getCmp('tipoCta')
                };

                cuentaStore.load({
                    params : {

                        tCta: Ext.getCmp('tipoCta')
                    }
                });
            }
        }
      },
      {
          id : 'cuenta',
          name : 'cuenta',
          xtype : 'combobox',
          fieldLabel : 'Cuenta',
          emptyText : '-Seleccionar-',
          store : cuentaStore,
          displayField : 'cuenta',
          valueField : 'cuenta',
          editable : false,
          forceSelection : true,
          triggerAction : 'all',
          allowBlank : false,
          blankText : 'Debe seleccionar unna cuenta.'
      } ,
      {
        xtype: 'radiogroup',
        id: 'formato',
        fieldLabel: 'Formato',
        items: [
          {boxLabel: 'Excel', name: 'fmtoval', inputValue: 1, checked: true},
          {boxLabel: 'PDF',   name: 'fmtoval', inputValue: 2},
          {boxLabel: 'CSV',   name: 'fmtoval', inputValue: 3}
        ]
      }],
    buttons: [btn, btn2]
});
    
asked by Luis 26.02.2016 в 21:10
source

1 answer

0

You can use a listener applied to radiogroup to know the selected value at each moment, with a simple event of onChange

xtype: 'radiogroup',
    id: 'formato',
    fieldLabel: 'Formato',
    items: [
      {boxLabel: 'Excel', name: 'fmtoval', inputValue: 1, checked: true},
      {boxLabel: 'PDF',   name: 'fmtoval', inputValue: 2},
      {boxLabel: 'CSV',   name: 'fmtoval', inputValue: 3}
],
listeners:{ change: this.onRadiogroupChange, scope: this }

This way you create the function onRadiogroupChange in your code and in it you can apply all the logic and functionality you want.

    
answered by 20.03.2017 в 10:48