Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在extjs4中的视图字段上加载json数据_Json_View_Grid_Extjs4 - Fatal编程技术网

如何在extjs4中的视图字段上加载json数据

如何在extjs4中的视图字段上加载json数据,json,view,grid,extjs4,Json,View,Grid,Extjs4,我在extjs4中工作。我认为- Ext.define('Balaee.view.qb.qbquestion.editWindow', {extend:'Ext.form.Panel', alias:'widget.editWindow', autoScroll:true, store:'qb.qbquestioncategoryStore', bodyStyle: 'padding: 20px', title: '<\center>U

我在extjs4中工作。我认为-

Ext.define('Balaee.view.qb.qbquestion.editWindow',
    {extend:'Ext.form.Panel',
    alias:'widget.editWindow',
    autoScroll:true,
    store:'qb.qbquestioncategoryStore',
    bodyStyle: 'padding: 20px',
    title: '<\center>Update-Question',
    items:[
           {
               xtype:'form',
               items:[{xtype:'hidden',
                        name:'questionId'
                    },
                    {border:false,
                       layout: 'hbox',
                       margin:'10 0 0 50',
                       items:[
                    {
                       margin:'5 0 5 50',
                       xtype:'textfield',
                       fieldLabel: 'Question',
                       name: 'question',
                       width:350,
                       emptyText: 'Enter the Question'
                   },
                    { margin:'5 0 5 10',
                        xtype: 'button',
                        id:'btn5',
                        //scale:'medium',
                        width:50,
                        //name: 'add',
                        text:' Delete  ',
                        action:'delete'                                  
                  }]
                    },

                  {
                       margin:'0 0 5 100',
                       xtype:'textfield',
                       fieldLabel: 'Keyword',
                       name: 'keyword',
                       width:350,
                       emptyText: 'Enter the related word'
                   },  
                  { margin:'0 0 5 100',
                       xtype:'combo',
                       fieldLabel: 'Language',  
                       width:250,
                        store:'qb.languageStore',
                        name: 'language',
                       //queryMode:'remote',
                       displayField:'language',
                       valueField:'languageId',
                       emptyText: '---Select---'
                   },
                   { 
                       margin:'0 0 5 50',
                       xtype:'combo',
                       id:'combo1',
                       fieldLabel: 'Elementary',
                       name: 'Elementary',
                       width:250,
                       store:'qb.qbcomplexityStore',
                       //queryMode:'low',
                       displayField:'complexityl',
                       valueField:'complexityId',
                       emptyText: '---Select---'
                   },
                   { margin:'0 0 5 50',
                       xtype:'combo',
                       id:'combo2',
                       fieldLabel: 'Intermediate',
                       name: 'Intermediate',
                       width:250,
                       store:'qb.qbcomplexityStore',
                       //queryMode:'low',
                       displayField:'complexityl',
                       valueField:'complexityId',
                       emptyText: '---Select---'                                 
                   },
                   { margin:'0 0 5 50',
                       xtype:'combo',
                       id:'combo3',
                       fieldLabel: 'Expert',
                       name: 'Expert',
                       width:250,
                       store:'qb.qbcomplexityStore',
                       //queryMode:'low',
                       displayField:'complexityl',
                       valueField:'complexityId',
                       emptyText: '---Select---'
                     },
                    {
                       margin:'0 0 5 100',
                       xtype:'textfield',
                       fieldLabel: 'Option',
                       name: 'option',
                       width:350,
                       emptyText: 'Enter the option',
                       id:'opts'
                   },
                   {
                       border:false,
                       layout: 'hbox',
                       margin:'7 0 5 100',
                       items:[ { //margin:'0 0 0 15',
                                   xtype: 'checkbox',
                                    fieldLabel: 'isAnswer',
                                   name: 'isAnswer',
                                    id:'anss1'
                               },
                               { 
                                     margin:'0 0 0 10',
                                     xtype: 'button',
                                     id:'btn3',
                                     //scale:'medium',
                                     width:50,
                                     //name: 'add',
                                     text:' Add  ',
                                     action:'add'                                    
                              } ] },
                    {
                       margin:'10 0 5 100',
                       xtype:'grid',
                       id:'grid1',
                       //title : 'Educational Details',
                       store:'qb.qbquestionoptionStore',
                       columns: [
                                 { 
                                     text: 'Options',
                                     dataIndex: 'option', 
                                     flex: 1
                                 }, 
                                 {
                                     text: 'Answer', 
                                     dataIndex: 'isAnswer', 
                                     flex: 2.5
                                 }
                       ],
                       height: 100,
                       width: 350
                   },
                   { 
                        margin:'0 0 5 200',
                        xtype: 'button',
                        id:'btn4',
                        //scale:'medium',
                        width:50,
                        //name: 'add',
                        text:' Update  ',
                        action:'update'  }]}});
我想在更新功能期间将此数据作为默认条目加载到上述视图的字段中。那么如何加载此数据呢?如何将json的optionarray[]绑定到id为“grid1”的网格?

为表单创建与字段匹配的。然后使用:

loadRecord:将Ext.data.Model加载到此表单中(内部仅调用 Ext.form.Basic.loadRecord)另请参见trackResetOnLoad

这将把您的模型绑定到一个表单,稍后您可以使用它将新数据更改为表单字段。下面是使用表单和模型绑定

{"data":[{"questionId":"29","question":"WRHEdsgdRHW","Elementary":"Low","Intermediate":"Low","Expert":"Low","keyword":"WFHRF","language":"english","Category":[{"category":"Main","id":"1"},{"category":"GK","id":"2"}],"optionarray":[{"option":"dfbsddfb"},{"option":"sdfgsd"},{"option":"sdgsd"}]}]}