Results 1 to 3 of 3

Thread: JSON Nested List to Checkbox

  1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Posts
    5
    Vote Rating
    0
      0  

    Default JSON Nested List to Checkbox

    HI,

    Is it possible to bind a nested array (the Roles in the following JSON) to checkboxes in a fieldset?

    [
    {
    "name": "User 1",
    "role": ["admin", "user", "partner"],
    },
    {
    "name": "User 2",
    "role": ["admin"],
    }
    ]

    Roles:
    [ ] superuser
    [x] admin
    [x] user
    [x] partner

    Regards,
    Marcel

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,388
    Vote Rating
    499
      0  

    Default

    You could create an ArrayStore and then use combo.store.loadData() to load the data.

    Regards,
    Scott.

  3. #3
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,154
    Vote Rating
    247
      0  

    Default

    Check out setValue for checkboxgroup:
    http://docs.sencha.com/ext-js/4-0/#!...ethod-setValue

    Code:
    var form = ?Ext.widget('form', {
        width: 400
        , renderTo: Ext.getBody()
        , items: [{
            xtype: 'checkboxgroup'
            , defaults: { name: 'role' }
            , items: [{
                boxLabel: 'Superuser'
                , inputValue: 'superuser'
            }, {
                boxLabel: 'Admin'
                , inputValue: 'admin'
            }, {
                boxLabel: 'User'
                , inputValue: 'user'
            }, {
                boxLabel: 'Partner'
                , inputValue: 'partner'
            }]       
        }]
    });
    
    
    Ext.widget('button', {
        text: 'Set Values'
        , renderTo: Ext.getBody()
        , handler: function () {
            var boxes = form.down('checkboxgroup');
            var data = [{"name": "User 1","role": ["admin","user","partner"]},{"name": "User 2","role": ["admin"]}];
            boxes.setValue(data[0]);
        }
    });
    ?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •