DeLe
DeLe

Reputation: 2480

Extjs4 - How to load check radiogroup from form.load

I have a form include a radiogroup like

{
 xtype: 'radiogroup',
        fieldLabel: 'group',
        name: 'a',
        items: [{
            boxLabel: '1',
            name: 'a',
            inputValue: '1'
        }, {
            boxLabel: '2',
            name: 'a',
            inputValue: '2',

        }, {
            boxLabel: '3',
            name: 'a',
            inputValue: '3'
        }]
    }

i using

form.load({         
     url: 'example.php',
....});

my json look like

{
    success:true ,
    data : {
       a:'2'    
    }
} 

But nothing work. How to fix that thanks

Upvotes: 1

Views: 1015

Answers (2)

dbrin
dbrin

Reputation: 15673

The problem is the name attribute on the radiogroup. It shouldn't be there at all or you can name it something else.

    xtype: 'radiogroup',
    fieldLabel: 'group',
    name: 'a'  <--- REMOVE

Here is your code sample in a fiddle. Instead of load() method on form i am using setValues method on the FormBasic becuase i don't have a server to load data from. But it works in the same way. http://jsfiddle.net/dbrin/JMmHz/

Essentially the problem is that it is looking for the first input element to match the name of the input value and is finding the radiogroup instead of the individual radio.

Upvotes: 2

kevhender
kevhender

Reputation: 4405

You need to add a callback method to the call, like this:

form.load({
    url: 'example.php', 
    success: function(response, options) {
      form.setValues(Ext.decode(response.data));
    }
});

Upvotes: 0

Related Questions