Take value and assign to a radioGroup

1

How can I take the value of a query to radioGroup ?
 Currently I have defined the radioGroup in this way:
the value that I store in a table is the one found in inputValue :

var chkTipoRRT = new Ext.form.RadioGroup({ id: 'chkTipoRRT', width: 400, columns: 4,
    items: [
    { name: 'chkTipoRRT', boxLabel: 'Estandar', inputValue: 'Estandar', checked: true },
    { name: 'chkTipoRRT', boxLabel: 'Doc', inputValue: 'Doc' },
    { name: 'chkTipoRRT', boxLabel: 'Plus', inputValue: 'Plus' }]
});

At the moment of consulting the table that contains my value (in this case it is "Plus") I do not know how to assign this value to this same radioGroup and show me the check corresponding to the value. I have this at the moment but it does not work for me:

(result.chkTipoRRT) ? (chkTipoRRT.setValue('plus')) : (chkTipoRRT.setValue('Doc'));
    
asked by user35221 03.04.2017 в 16:29
source

2 answers

1

I validate that the invocation to remote.aspx is correct, I also imagine this page exposes a webmethod of name getRecepcion , if so you could make the answer is the value of the radius that should be selected.

Ext.Ajax.request({ url: 'remote.aspx', tiemeout: 10000, params: { opcion: 'getRecepcion', id: id }}, 
                success: function(response) { 
                    var result = Ext.decode(response.responseText); 
                    if (result.success) { 
                        chkTipoRRT.setValue(result.chkTipoRRT); 
                    }
                });

in this case result.chkTipoRRT would return Doc, Plus, etc

To see the value you receive, you could define the line

console.log(result.chkTipoRRT);

in success and if you use the browser's Developr Tools, which you access with F12, in the tab Console see the value

To assign the value you could use

var checkName = "chek" + result.chkTipoRRT
Ext.getCmp(checkName).setValue(true);
    
answered by 03.04.2017 / 17:58
source
0

How did I find the solution to show the value first modify the radioGroup in this way:

var chkTipoRRT = new Ext.form.RadioGroup({ id: 'chkTipoRRT', disabled:true, width: 400, columns: 4,
        items: [
        { name: 'chekEstandar', id: 'chekEstandar', boxLabel: 'Estandar', inputValue: 'Estandar' },
        { name: 'chekDoc', id: 'chekDoc', boxLabel: 'Doc', inputValue: 'Doc' },
        { name: 'chekPlus', id: 'chekPlus', boxLabel: 'Plus', inputValue: 'Plus' },
        { name: 'chekPersonalizada', id: 'chekPersonalizada', boxLabel: 'Personalizada', inputValue: 'Personalizada'}]
    });

assign id and change name to identify each of the checks.

in the function to bring the result value handle it this way:

 function datosRecepcion(id) {
        Ext.Ajax.request({
            url: 'remote.aspx',
            tiemeout: 10000,
            params: { opcion: 'getRecepcion', id: id },
            success: function(response) {
                var result = Ext.decode(response.responseText);
                if (result.success) {
                    var chkRRT = result.chkTipoRRT;
                    if (chkRRT == 'plus') { Ext.getCmp('chekPlus').setValue(true); }
                    if (chkRRT == 'estandar') { Ext.getCmp('chekEstandar').setValue(true); }
                    if (chkRRT == 'doc') { Ext.getCmp('chekDoc').setValue(true); }
                    if (chkRRT == 'personalizada') { Ext.getCmp('chekPersonalizada').setValue(true); }
                } else {
                    msg(result.msg, Ext.Msg.OK, Ext.Msg.WARNING);
                }
            },
            failure: function(result, request) {
                msg('Ocurri%oacute; un error en la aplicación', Ext.Msg.OK, Ext.Msg.ERROR);
            }
        });
    };

which validates the value of the query and according to the value that was obtained is assigned the checked in true.

    
answered by 03.04.2017 в 18:54