1. #1
    Sencha User
    Join Date
    Mar 2012
    Location
    Jakarta
    Posts
    30
    Vote Rating
    2
    arivwd is on a distinguished road

      0  

    Default Checkbox in CheckboxGroup checked property always false after dynamically add

    Checkbox in CheckboxGroup checked property always false after dynamically add


    First i drew this

    Code:
    var getRequest = function () {
        var getRequest2 = function() {
            Ext.Ajax.request({
                url: '/system_users/system_groups/data/0',
                callback: function(opt, success, response) {
                    if (success) {
                        var result = Ext.decode(response.responseText);
                        createItem(result);
                    }
                }
            });
        }
        ....
        getRequest2();
    };
    
    function createItem(result) {
        var checkboxGroup = form_SystemUsers.items.items[2].items.items[0].items.items[3].items.items[0].items.items[0];
        checkboxGroup.removeAll();
        var rec = result.dataRecords;
            var checkbox = new Ext.form.Checkbox({
                xtype: 'checkbox',
                checked: true,
                name: 'ck0['+i+']',
                inputValue: rec[i].sys_usergroup_id,
                boxLabel: rec[i].sys_usergroup_name
            });
            checkboxGroup.items.add(checkbox);
        };
        form_SystemUsers.updateLayout();
    }
    when the form_SystemUsers rendered, i call the function

    Code:
    getRequest();
    and.. the checkboxes in checkboxgroup appear with checked status true.. and then false (blink)..
    what's wrong?

  2. #2
    Sencha User
    Join Date
    Mar 2012
    Location
    Jakarta
    Posts
    30
    Vote Rating
    2
    arivwd is on a distinguished road

      0  

    Default


    i think the problem is in checkboxGroup.removeAll();

    if i remove that line, everytime i call "getRequest();"checkboxes appears and do multiple.
    at first result, the checked status are false, BUT the next other are true.
    what should i do?

  3. #3
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    7,185
    Vote Rating
    194
    scottmartin is a splendid one to behold scottmartin is a splendid one to behold scottmartin is a splendid one to behold scottmartin is a splendid one to behold scottmartin is a splendid one to behold scottmartin is a splendid one to behold scottmartin is a splendid one to behold

      0  

    Default


    What is your overall goal .. not sure I follow your intention here when you call returns.

    Scott.

  4. #4
    Sencha User
    Join Date
    Mar 2012
    Location
    Jakarta
    Posts
    30
    Vote Rating
    2
    arivwd is on a distinguished road

      0  

    Default


    I'm trying to add items to checkboxgroup and give em "checked" status to "true" after form rendered.
    The "checked" status come from "ajax.request" response.
    I've called "doLayout" after that.
    Yes, the items (checkboxes) appear with "checked" status "true" (checked) but then (after milliseconds) it turn to "false" (unchecked).
    What do i wrong?

    This is the form layout.
    users.jpg

  5. #5
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    7,185
    Vote Rating
    194
    scottmartin is a splendid one to behold scottmartin is a splendid one to behold scottmartin is a splendid one to behold scottmartin is a splendid one to behold scottmartin is a splendid one to behold scottmartin is a splendid one to behold scottmartin is a splendid one to behold

      0  

    Default


    Is the checkbox group visible before the ajax call, or added after the call is successful?

    My point here is ...

    In your description of the problem, it sounds like you have a checkbox group available, they are getting checked and you are then creating a new instance that is placed on top of the previous one.

    Code:
    var checkbox = new Ext.form.Checkbox({
     ...
    });
    I would think that checkbox group should already be on the form and you just need to get that instance and update the checks .. and not create a new instance.

    Scott.