1. #1
    Sencha User
    Join Date
    Sep 2008
    Posts
    66
    Vote Rating
    0
    barbara1712 is on a distinguished road

      0  

    Default read the data from database and display checkbox group in form

    read the data from database and display checkbox group in form


    Hi ,
    I want to read the data from database and display the values in chekbox group and then display the form.
    I have created a store. on load listener, I read the data and store the data in an array. and this array I want to set as items for my checkboxgroup. Please check the below code
    HTML Code:
    var arrRatings = [];
    var arrReader = new Ext.data.JsonReader({
            root: 'data',
            totalProperty:'totalCount'    
        }, [
            {name: 'id', mapping:'id'},
            {name: 'ratings', mapping:'ratings'}
        ]
        )
    
    arrRatStore = new Ext.data.Store({
            url:'./CentralController.php?menu_no_top=perf_review&reviewcode=INITAPPR&action=loadRatingsData',
            reader:arrReader,
            autoLoad:true,
            listeners:{
                load:function(a,records,options){
                    for(i=0; i < records.length; i++){
                        arrRatings.push(
                            {
                                boxLabel:records[i].data.ratings,
                                name:'chkRatings[]',
                                inputValue: records[i].data.id,
                                checked:'false'
                            }
                        )
                    }               
                }        
            }    
        });
    
    myform= new Ext.FormPanel({
            id:'myform',
            name:'myform',
            buttonAlign:'right',
            url:'myurl',
            border:false,
            title:'My Form',
            layout:'table',
            width:600,
            items:[
                   {
                        xtype: 'checkboxgroup',
                        name: 'chkRatings',
                        id:'chkRatings',
                        fieldLabel: ' Define Ratings:',
                        columns:3,
                        items:arrRatings                    
                    }
            ]
    });
    
    //arrRatStore.load();
    myform.render(document.body);
    //arrRatStore.load();
    Please help me.
    Thanks in advance.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,641
    Vote Rating
    434
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    What is your JSON response looking like?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Sep 2008
    Posts
    66
    Vote Rating
    0
    barbara1712 is on a distinguished road

      0  

    Default


    Hi Thanks for reply. This is my json

    {"success":true,"totalCount":6,"data":[{"id":"1","ratings":"Outstanding"},{"id":"2","ratings":"Excellent"},{"id":"3","ratings":"Exceeds Expectations"},{"id":"4","ratings":"Meets Expectations"},{"id":"5","ratings":"Falls short of Expectations"},{"id":"6","ratings":"Needs Improvement"}]}