s.webbandit
s.webbandit

Reputation: 17000

Checkbox doesn't get selected in ExtJS 4.1

I load form data from server and filling form with it.

    var form = this.getPForm().getForm().load({
        url: '/url',
        params: {
            id: record.get('id'),
        },
    });

All goes OK except one checbox, which doesn't get checked even its input data is true

            {
                fieldLabel: 'name',
                name: 'name',
                minLength: 5,
                maxLength: 80,
            }, {
                xtype: 'checkbox',
                fieldLabel: 'Yes?',
                name: 'yes',
                inputValue: '1',
                uncheckedValue: '0',
                    listeners:{                 
                    change:function(c){

                        alert(c.getValue());

                    }
                },
            }, 

On Form load I get true alert message informing that form data has acheved checkbox and is changing. But checkbox doesn't get checked!

Upvotes: 2

Views: 2640

Answers (2)

s.webbandit
s.webbandit

Reputation: 17000

Resolved my issue. Problem was in same name properties at two different checkboxes. Thank all for taking time.

Upvotes: 1

sra
sra

Reputation: 23973

The load-operation above says nothing at all concerning your issue... As JohnnyHK stated, what data do you receive (load into the form) From your comments I guess you are receiving a boolean value therefore I would recommend you to use

inputValue: 'true', 
uncheckedValue: 'false'

even if

inputValue: '1', 
uncheckedValue: '0'

should compare equal, using plain javascript. You might also try setting a default startvalue

value: true, 
checked: true

At least I do it this way and it work for me. If this don't help, please post the data you are receiving from the server.

Upvotes: 1

Related Questions