-
5 Jul 2012 5:11 AM #1
Checkbox in CheckboxGroup checked property always false after dynamically add
Checkbox in CheckboxGroup checked property always false after dynamically add
First i drew this
when the form_SystemUsers rendered, i call the functionCode: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(); }
and.. the checkboxes in checkboxgroup appear with checked status true.. and then false (blink)..Code:getRequest();
what's wrong?
-
5 Jul 2012 9:00 AM #2
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?
-
5 Jul 2012 9:08 AM #3
What is your overall goal .. not sure I follow your intention here when you call returns.
Scott.
-
6 Jul 2012 2:06 AM #4
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
-
6 Jul 2012 8:28 AM #5
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.
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.Code:var checkbox = new Ext.form.Checkbox({ ... });
Scott.



Reply With Quote