使用 EXTJS v4,我想更新我拥有的多选组合框的 VALUE 字段,以及从我的远程查询返回的所有记录。在我的情况下,我想更新多选“值”字段而不是“值字段”条目,并突出显示从组合列表的数据库查询返回的列表中的值。对于组合框,如果您将组合设置为使用如下配置条目运行:
displayField:'TABLENAME',valueField:'TABLENAME',值:['table1','table2','table5'],
然后在创建组合时,如果您打开组合,您将看到这 3 个条目突出显示。
我想进行远程调用,获取返回的值列表,然后将它们传递回组合框,以便它们在组合框中显示为突出显示的条目。
这是我到目前为止所拥有的:
[code]
Ext.Ajax.request({
url : 'app/store/dbcall/target/GG/table_list_containing_target_svc.php',
params : { groupflavor_sn: theGroupFlavor_sn, familyName: familyName },
method : 'POST',
success : function(response, theRecord) {
var res = Ext.JSON.decode(response.responseText);
var returnedTablesData = res.data;
// reurned values are either 'blank', or a list of tablenames formatted as JSON.
// JSON responses will look like this:
// {"data":[{"TABLENAME":"TABLE_A1"},{"TABLENAME":"TABLE_A1B"},{"TABLENAME":"TABLE_A5"}]}
// combobox object:
/*
var msForm = Ext.widget('form', {
title: 'Tables found for ' + selectedFamily,
//width: 385,
height: 150,
bodyPadding: 10,
id: 'msForm',
layout: 'fit',
items:[{
xtype: 'combobox',
id: 'myTablesComboId',
name: 'myTargets',
maxHeight: 150,
width: 210,
multiSelect: true,
emptyText : "Select targets",
store: 'TableComboStore',
displayField: 'TABLENAME',
valueField: 'TABLENAME',
value: ['TABLE_A1', 'TABLE_A10B', 'TABLE_A5'], //<- this is what will be highlighted in the combo list
forceSelection: false,
editable: false,
queryMode: 'local',
ddReorder: true,
triggerAction: 'all',
listeners: {
'click': function() {
if (selectedFamily) {
console.log('family selected, and button clicked');
}
}
},
listConfig: {
getInnerTpl: function(displayField) {
return '<tpl for="."><div><img src="' + Ext.BLANK_IMAGE_URL + '" ' + 'class="ux-checkboxlistcombo-icon">{' + (displayField || 'text') + ':htmlEncode}</div></tpl>';
}
}
}]
})
*/
// Post value to field
Ext.getCmp('theTargetLabel').setValue(theGroupFlavor);
if (res.data === 'blank') {
console.log("res.data === 'blank'");
// Entry is found in the database, so clear all values, and ask to resend
var theTableCombo = Ext.getCmp('myTablesComboId');
Ext.getCmp('theTargetLabel').setValue(' ');
theTableCombo.clearValue();
}
else {
// list of available tables returned as JSON
// populate list returned into the new table combo, and update with the existing list of tables
// values returned will be HIGHLIGHTED and the checkbox next to value will be CHECKED in the listing
var theTableCombo = Ext.getCmp('myTablesComboId');
var store = theTableCombo.getStore();
theTableCombo.setValue(returnedTablesData); // this works partially, to return all records found, but they are not highlighted in the combo list
//theTableCombo.setValue(store.getAt(0).get('TABLENAME')); // this works partially - record is highlighted in combo list, but only returns the first record
}
});
[/code]
正如您所看到的,当我们进入“else”语句时,有一个表列表我可以发回组合。但是我得到了返回的列表,但它们只显示在组合文本字段中,当我打开组合时,这些值没有突出显示。
如果我使用 - theTableCombo.setValue(store.getAt(0).get('TABLENAME'));- 我能够检索返回的第一条记录并在组合中突出显示该记录,但只有第一条记录。我希望所有返回的记录都显示在组合中,作为突出显示的条目。