如何从SQL查询中填充复选框组



我有一个查询,它返回表中的所有列标题。我想用查询返回的值填充组中每个复选框的值框标签。id节点将是值,文本节点将是复选框标签。

查询由存储加载事件中的ActionName启动。

这是我的代码

{
xtype       : 'checkboxgroup',
fieldLabel  : 'Column Names',
id          : 'chkColumnNames',
itemId      : 'chkColumnNames',
cls         : 'x-check-group-alt',
// Distribute controls across 5 even columns, filling each row
// from left to right before starting the next row
columns: 5,
store          : Ext.create('Ext.data.Store', {
model    : 'Personnel.ART.String.ChoiceList',       
autoLoad : true,
sorters: [{
property: 'text',
direction: 'ASC'
}],
proxy    : {
type     : 'ajax',
url      : IXYZ.portal.path + 'IXYZDBService.asmx/jsonSQLActions',
actionMethods : {read : 'POST'},
extraParams : {
AppAcronym      : IXYZ.application.acronym, 
WFAcronym       : IXYZ.workflow.acronym,
Process_id      : -1,
ActionName      : 'ART.SELECT.ADHOC.COMBINED_PERSONNEL.COLUMN.NAMES',
suppressLog     : true,
tokenProcessing : 'False'
},
reader   : {type : 'xml', record : 'row'}
},
listeners      : {
load: function(store, records, successful) {
columnNamesCheckbox = Ext.getCmp('chkColumnNames');
var columnNameItems = [];
for(var i = 0; i < records.length; i++) {
columnNameItems.push({id: records[i].data.id, boxLabel: records[i].data.text}); 
}
}
}
}),
items: [
]
}

以下是来自查询的xml

<row id="PersonnelID" text="PersonnelID" />
<row id="UserID" text="UserID" />
<row id="FirstName" text="FirstName" />
<row id="LastName" text="LastName" />
<row id="MiddleName" text="MiddleName" />
<row id="PreferredName" text="PreferredName" />
<row id="HomePhone" text="HomePhone" />
<row id="WorkEmail" text="WorkEmail" />
<row id="bActing" text="bActing" />
<row id="HomeAddress" text="HomeAddress" />
<row id="GSLevel" text="GSLevel" />

以下是对我有效的方法。由于我在商店中运行代码,我按id引用了复选框组,然后循环浏览记录,并使用checkboxgroup.add填充复选框组

{
xtype       : 'checkboxgroup',
fieldLabel  : 'Column Names',
id          : 'chkColumnNames',
itemId      : 'chkColumnNames',
cls         : 'x-check-group-alt',
// Distribute controls across 5 even columns, filling each row
// from left to right before starting the next row
columns: 5,
store          : Ext.create('Ext.data.Store', {
model    : 'Personnel.ART.String.ChoiceList',       
autoLoad : true,
sorters: [{
property: 'text',
direction: 'ASC'
}],
proxy    : {
type     : 'ajax',
url      : ICWF.portal.path + 'ICWFDBService.asmx/jsonSQLActions',
actionMethods : {read : 'POST'},
extraParams : {
AppAcronym      : ICWF.application.acronym, 
WFAcronym       : ICWF.workflow.acronym,
Process_id      : -1,
ActionName      : 'ART.SELECT.ADHOC.COMBINED_PERSONNEL.COLUMN.NAMES',
suppressLog     : true,
tokenProcessing : 'False'
},
reader   : {type : 'xml', record : 'row'}
},
listeners      : {
load: function(store, records, successful) {
var checkboxgroup = Ext.getCmp('chkColumnNames');
for(var i = 0; i < records.length; i++) {
//ICWF.reports.itemArray.push({id: records[i].data.id, boxLabel: records[i].data.text});
checkboxgroup.add({
xtype: 'checkbox',
inputValue: records[i].data.id,
boxLabel: records[i].data.text,
//checked: rec.get(cField),
//name: 'fName'
});
}
debugger;
}
}
}),
items: []
}

最新更新