【问题标题】:issue - dynamically populating checkbox group from database(MYSQL) in extjs 4问题 - 从 extjs 4 中的数据库(MYSQL)动态填充复选框组
【发布时间】:2012-12-03 19:58:53
【问题描述】:

我在 extjs 4 中从数据库(MYSQL)动态填充复选框组时遇到问题。下面是我通过搜索论坛尝试的代码。请告知需要做什么才能使其正常工作。

(i) 我有一个 ArrayStore 如下:

           var checkboxArray1 = [];
     var arrayStore=   new Ext.data.ArrayStore({
      autoLoad:false,
      proxy: {
             type: 'rest',
             url: 'xxxxxxx',
             reader: {
                 type: 'json',
                 root: 'doThisStore'
             }  
      },
      fields : ['vcName','vcId'],
      listeners: {                                                                           

             load: function(t, records, options) {                                                  

                 for(var i = 0; i < records.length; i++) {  

                   checkboxArray1.push({name: records[i].data.vcId, boxLabel: records[i].data.vcName});  
                   alert(checkboxArray1[i].name);
                   alert(checkboxArray1[i].boxLabel);
                 }                                                                                  
             }                                                                                      
         }      
     });

(ii) 我的“字段集”如下:

{
                        xtype : 'fieldset',
                        title : "Systems",
                        collapsed:false,
                        checkboxToggle: true,
                        anchor : '100%',
                        defaults : {
                            msgTarget : 'side',
                            allowBlank : true
                        },
                        items:{
                           xtype: 'checkboxgroup',
                         fieldLabel: 'dothis',
                         columns: 3,
                         vertical: true,
                         items: checkboxArray1

                    }},

感谢您的帮助。

【问题讨论】:

    标签: extjs4


    【解决方案1】:

    首先将 ID 分配给复选框组的项目,然后将该 ID 用作

    Ext.getCmp('Your Id').add(CheckBoxArray1);
    

    【讨论】:

    • 它可以工作,但 add() 是私有方法,extjs 不授予私有方法的功能,因此在下一个版本的 extjs 框架中,可能会 add() 功能发生变化,并且 add 不能正常工作跨度>
    猜你喜欢
    • 1970-01-01
    • 2013-03-04
    • 2014-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-12
    • 1970-01-01
    • 2019-01-07
    相关资源
    最近更新 更多