我在網格內有2個組合框。第二個組合框值將根據第一個組合框進行更改。
例如組合有3個項目:美國,歐洲,亞洲。
如果在第一個組合框中選擇了歐洲,那麼在第二個組合框中,歐洲不會再出現。
當已經選擇時隱藏組合框的值extjs
我不知道我用它的ExtJS的版本,
但這裏的代碼:
我的組合STORE
我的組合INSIDE GRID
var set_approval_dtl = Ext.create('Ext.Window', {
title: title_approval2, width: 850, height: 395, rowdblclick: true, forceFit: true,
closeAction: "hide", store: ms_set_approval_dtl_store,
defaults: {
sortable: true, resizable: false
},
items: [
{xtype: "form", items: [
{layout: 'column', columnWidth: .5, itemId: 'set_approve', defaults: {border: false},
items: [{xtype: "panel", itemId: "set_approve_panel", height: 330, defaultType: 'textfield', margin: '0 10px 0 10px',
defaults: {labelWidth: 120, width: 850, maxLength: 200},
items: [
{xtype: "grid", itemId: "grid_items", width: 782, height: 280, margin: '0 10px 10px 10px', autoScroll: true,
plugins: Ext.create('Ext.grid.plugin.CellEditing', {clicksToEdit: 1, pluginId: 'rowEditing'}),
store: ms_set_approval_dtl_store, stripeRows: true, defaultType: "gridcolumn",
viewConfig: {forceFit: true},
columns: [
{header: grid18j, width: 150, dataIndex: 'nm_act', align: 'center'},
{header: subtitle_approval3, width: 126, dataIndex: 'level1', align: 'center',
editor: {xtype: "combobox", name: "cdgr", itemId: "cdgr1", typeAhead: true, editable: false, triggerAction: "all", forceSelection: true,
emptyText: grid8k, store: cb_group, valueField: "id", displayField: "nm",
listeners: {
expand: function(field, options, val) {
if (Ext.typeOf(field.getPicker().loadMask) !== "boolean") {
field.getPicker().loadMask.hide();
}
},
select: function(value) {
var obj = this.lastSelection[0].data;
return obj.nm;
this.lastSelection[0].hide;
cb_group.removeAt(0);
}
}},
renderer: function(val) {
var index = cb_group.findExact('id', val);
if (index !== -1) {
var rs = cb_group.getAt(index).data;
return rs.nm;
}
}
},
{header: subtitle_approval4, width: 126, dataIndex: 'level2', align: 'center', itemId: "level2",
editor: {xtype: "combobox", name: "cdgr", itemId: "cdgr2", typeAhead: true, editable: false, triggerAction: "all", forceSelection: true,
emptyText: grid8k, store: cb_group, valueField: "id", displayField: "nm",
listeners: {
expand: function(field, options) {
if (Ext.typeOf(field.getPicker().loadMask) !== "boolean") {
field.getPicker().loadMask.hide();
}
}
}
},
select: function(value) {
var obj = this.lastSelection[0].data;
return obj.nm;
},
renderer: function(val) {
var index = cb_group.findExact('id', val);
if (index !== -1) {
var rs = cb_group.getAt(index).data;
return rs.nm;
}
}
}]
}]}
]}]}
]});
我試過this.lastSelection [0] .hide;和cb_group.removeAt(0);在第一個組合。但它根本不起作用。我不知道爲什麼我的選擇監聽器不工作。
請分享一些解決方案。謝謝
所以我必須爲每個組合框2個商店? 以及我在哪裏放置你上面提到的功能?外部var set_approval_dtl? – 2014-10-09 07:13:48
兩個組合框中的每一個的一個商店總共是兩個商店。您可以將我的函數放入'listeners:{select:function(combo,newVal)...',因爲在組件上使用偵聽器對象與使用'component.on()'相同。 – Alexander 2014-10-09 07:37:12
哦,所以每個組合框有不同的商店,但數據是相同的? 我不能只調用組合框名稱。它在螢火蟲上出現錯誤,說我的組合名稱沒有定義。 – 2014-10-09 07:41:31