-
8 Oct 2012 8:25 PM #1
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
Please help me.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();
Thanks in advance.
-
15 Oct 2012 2:13 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,641
- Vote Rating
- 434
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.
-
16 Oct 2012 10:32 PM #3
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"}]}


Reply With Quote