1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    9
    Answers
    1
    Vote Rating
    0
    tamri is an unknown quantity at this point

      1  

    Default Unanswered: extjs4 STORE into CheckboxGroup

    Unanswered: extjs4 STORE into CheckboxGroup


    I create store, load records and want to fill CheckboxGroup with it. but I can't show CheckboxGroup in the form.
    records is loaded, but checkboxes not displayed.
    there is my code. i spend hole day, read all recommendations ...
    what is wrong ??
    anyone help !
    Code:
       var checkboxes = [];
    var resourceVacancesStore = Ext.create('Ext.data.Store', {
           model:operationTypeModel,
           proxy: 
            {   
               type: 'ajax'    ,              
               url:'url',
               idProperty: 'oId',
               autoLoad:true,        
                 reader: {
                     type: 'json',   
                   root: 'data'} 
            }    ,
            listeners: {                                                                                                                         
            load: function(t, records, options) {   
            var checkboxconfigs=[];
                for(var i = 0; i < records.length; i++) {                    
                    checkboxconfigs.push({
                         name: records[i].data.oId,
                         inputValue: records[i].data.oNameEn,
                         boxLabel : records[i].data.oNameEn,
                         xtype: 'checkbox'
                     });                  
                     processItems(checkboxconfigs);                 
                }
            }                                                                                                                                  
        }  
       });
    
       function processItems(items){
         checkboxes =items;
        }
    
       var myCheckboxgroup = new Ext.form.CheckboxGroup({
            id:'myGroup',
            fieldLabel: 'Checkboxes in two columns',
            items:checkboxes ,
            renderData :main
        });
       resourceVacancesStore.load();

  2. #2
    Sencha User lucasguaru's Avatar
    Join Date
    May 2011
    Location
    Guarujá, Brazil
    Posts
    77
    Answers
    9
    Vote Rating
    1
    lucasguaru is on a distinguished road

      0  

    Default


    You can try to create the checkboxgroup when the store loads.
    Code:
    var resourceVacancesStore = Ext.create('Ext.data.Store', {
        model : operationTypeModel,
        proxy : {
            type : 'ajax',
            url : 'url',
            idProperty : 'oId',
            autoLoad : true,
            reader : {
                type : 'json',
                root : 'data'
            }
        },
        listeners : {
            load : function(t, records, options) {
                var checkboxconfigs = [];
                for ( var i = 0; i < records.length; i++) {
                    checkboxconfigs.push({
                        name : records[i].data.oId,
                        inputValue : records[i].data.oNameEn,
                        boxLabel : records[i].data.oNameEn,
                        xtype : 'checkbox'
                    });
                }
                var myCheckboxgroup = new Ext.form.CheckboxGroup({
                    id : 'myGroup',
                    fieldLabel : 'Checkboxes in two columns',
                    items : checkboxconfigs,
                    renderData : main
                });
            }
        }
    });
    The problem is if you loads the store many times.

  3. #3
    Sencha User skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,338
    Answers
    498
    Vote Rating
    248
    skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of

      0  

    Default


    Something like this perhaps?

    Code:
    var myCheckboxGroup = Ext.create('Ext.form.CheckboxGroup', {
        fieldLabel: 'Checkboxes in two columns',
        renderTo: Ext.getBody()
    });
    
    var resourceVacancesStore = Ext.create('Ext.data.Store', {
        autoLoad: true,
        model: operationTypeModel,
        listeners: {
            load: function(store, records) {
                myCheckboxGroup.removeAll();
    
                myCheckboxGroup.add(Ext.Array.map(records, function(record) {
                    return {
                        boxLabel: record.get('oNameEn'),
                        inputValue: record.get('oNameEn'),
                        name: record.get('old')
                    };
                }));
            }
        },
        proxy: {
            type: 'ajax',
            url: 'url',
            reader: {
                root: 'data',
                type: 'json'
            }
        }
    });

  4. #4
    Sencha User
    Join Date
    Aug 2011
    Posts
    9
    Answers
    1
    Vote Rating
    0
    tamri is an unknown quantity at this point

      0  

    Default


    it does not work, maybe there are other problems.

    myCheckboxGroup not shows records

  5. #5
    Sencha User skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,338
    Answers
    498
    Vote Rating
    248
    skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of

      0  

    Default


    Shove in some breakpoints, check if the code's running and what happens when it does.

  6. #6
    Sencha User
    Join Date
    Aug 2011
    Posts
    9
    Answers
    1
    Vote Rating
    0
    tamri is an unknown quantity at this point

      -1  

    Default


    now it works!
    solution :
    it didn't work until i don't have written layout on checkboxgroup (layout is not required config in the documentation).

    thank's!

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar