1. #1
    Sencha User
    Join Date
    Mar 2011
    Posts
    12
    Vote Rating
    0
    jodyford is on a distinguished road

      0  

    Default Creating CheckBoxGroup from JSON/Array Store -ERROR

    Creating CheckBoxGroup from JSON/Array Store -ERROR


    I'm trying to create checkboxes from an array. Utimatley I want to tie this to JSON. I have the following sample code:

    <code>
    var Stakeholder_CheckBoxArray = []; //temp stakeholder store
    var Stakeholders_Store = new Ext.data.ArrayStore({
    fields: ['Id', 'Text'],
    data: [['1', 'item1'], ['2', 'item2'], ['3', 'item3']],
    listeners: {
    load: function (t, records, options) {
    for (var i = 0; i < records.length; i++) {
    Stakeholder_CheckBoxArray.push({ name: records[i].data.Id, boxLabel: records[i].data.Text });
    // alert(records[i].data.Text);
    }
    }
    }
    });
    var stakeholder_checkboxes = new Ext.form.CheckboxGroup({
    id: 'shakeholder_checkboxes',
    name: 'broker',
    flex: 4,
    allowBlank: true,
    columns: 1,
    items: [Stakeholder_CheckBoxArray]
    });
    </code>

    The output is one checkbox with no text. The "alert" works correctly when uncommented. Obvoiusly, this is not the desired output. What am I doing wrong?


    Thanks,

    JRF

  2. #2
    Sencha User
    Join Date
    Mar 2011
    Posts
    12
    Vote Rating
    0
    jodyford is on a distinguished road

      0  

    Default Update...

    Update...


    Here's some updated code that gets data from an ashx file... but the checkboxes are still not rendering correctly.
    Code:
                
    
    var Stakeholder_CheckBoxArray = []; //array of about to be checkboxes.   
                
    var Stakeholders_Store = new Ext.data.ArrayStore({
                autoLoad: true,
                method: 'GET',
                fields: ['Id', 'BoxLabel'],
                root: 'd',
                id: 'Id', 
                proxy: new Ext.data.HttpProxy({
                url: 'stakeholders.ashx' 
             }),
                listeners: {
                load: function (t, records, options) {
                    for (var i = 0; i < records.length; i++) 
                    {
                        Stakeholder_CheckBoxArray.push({ inputValue:records[i].data.Id, boxLabel:records[i].data.BoxLabel });
                    }
                    }}});
           
    var stakeholder_checkboxes = new Ext.form.CheckboxGroup({
                id: 'shakeholder_checkboxes',
                //name: 'broker',
                flex: 4,
                allowBlank: true,
                columns: 1,
                items: [Stakeholder_CheckBoxArray]
            });
    

  3. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    12
    Vote Rating
    0
    jodyford is on a distinguished road

      0  

    Default Answred: This works

    Answred: This works


    This code works.

    Code:
        var stakeholder_checkboxes = new Ext.form.CheckboxGroup({
            id: 'shakeholder_checkboxes',
            flex: 4,
            allowBlank: true,
            columns: 1
        });    var Stakeholders_Store = new Ext.data.JsonStore({
            autoLoad: true,
            method: 'GET',
            fields: ['Id', 'BoxLabel'],
            root: 'd',
            id: 'Id',
            proxy: new Ext.data.HttpProxy({
                url: 'stakeholders.ashx'
            }),
            listeners: {
                load: function (t, records, options) {
                    var i = 0;
                    for (var i = 0; i < 3; i++) {
                        var cb = Ext.create('Ext.form.field.Checkbox', {
                            boxLabel: records[i].data.BoxLabel,
                            inputValue: records[i].data.Id
                        });
                        stakeholder_checkboxes.add(cb);
                    }
                }
            }
        });

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