javascript - How to fill an Ext.form.CheckboxGroup with checkboxes generated based on a JSON object returned from a server -


I dynamically try to fill Ext.form.CheckboxGroup to Ext I am here. Form derived from JSON object pulled from JSF page Checkbox s looks like my JSON object:

  {"sensor": [{"id": 200, "name": "name - b - a"}, {"Id": 201, "name": "name -b -b"}, {"id": 202, "name": "name-c -a"}, {"id": 203, "name" : "Name-c -b"}]}   

I can load these items in the code in the Ext.data.JsonStore in such a way: / P>

  New Ext.data.JsonStore ({id: 'sensorstore', auto-load: correct, method: 'GET', base-based: {job type: 'sensor'}, url: ' Getstatus.jsp ', root:' sensor ', sortoinfo: field: [' id ',' name ']}),   

I understand that it will give me access to a set of Ext.data.Record objects, but I can not understand that any Ext.form.Checkbox s How to go about making those records go about, or if there is any other way to get the same results.

I am not trying to set the checkbox values, although I must be able to reference them while submitting the form.

Assume that the store is loading (since you have automatically loaded: true)

  1. Re-record
  2. Add your checkbox group to your form (or whatever container) and check box group objects (items configured form Using the array created in the # 1 above). Call this container's delay () if it has already been provided

    Snippet to create and configure a checkbox -

      var Checkbox configured = []; About the check box // array Mystore.getRange (). Each (function (record) {checkboxconfigs.push (push in // // array ID: record.data.id, boxLabel: record.data.name, // any other checkbox properties, layout related or whatever});} ); Snippet to create a checkbox group -  
      var myCheckboxgroup = new Ext.form.CheckboxGroup ({id: 'myGroup', fieldLabel: 'check box in two columns', column: 2, item: checkbox Configure / // // other checkbox group configuration in the previous snippet});   

    Add it to your container and recreate it -

      mycontainer.add (myCheckboxgroup) .doLayout (); Edit - Your JasonStore does not match configured data (id should be an integer)  
      New Ext.data.JsonStore ({ Id: 'sensor', auto-load: correct, method: 'GET' Id ', direction:' ASC '}, field: [{name:' id ', type: int},' name ']}),    

Comments