//扩展重写TriggerField
Ext.form.ShiftDefRefContentTab = Ext.extend(Ext.form.TriggerField, {
triggerClass : 'x-form-ref-trigger',
fieldLabel : ' 选择节目包标识 ',
name : 'contentId',
width : 150,
initComponent : function() {
Ext.form.ComboBox.superclass.initComponent.call(this);
this.ds = new Ext.data.Store({// 任务日志的Store
proxy : new Ext.data.HttpProxy({
url : "listContentGrid.action"
}),
reader : new Ext.data.JsonReader({
root : 'root'
}, [{
name : "contentTypeTab.typeName"
}, {
name : 'secOperator.logonName'
}, {
name : 'metaDefineTab.chupingren'
}, {
name : 'name'
}, {
name : 'contentId'
}, {
name : 'createTime'
}, {
name : 'contentId'
}])
})
this.ButtonOK = new Ext.Button({
id : 'RefButtonOK',
text : '添加记录',
// iconCls : 'x-icon-subscriptions',
tooltip : '添加',
// Cls : 'images/business/image_add.png'
iconCls : 'images/add.png'
});
this.sm = new Ext.grid.CheckboxSelectionModel();
this.cm = new Ext.grid.ColumnModel([this.sm, {
header : "包名称",
dataIndex : 'name',
align : 'center'
}, {
header : '类型',
dataIndex : 'contentTypeTab.typeName',
// width : 150,
align : 'center'
}, {
header : '出品人',
dataIndex : 'metaDefineTab.chupingren',
// width : 150,
align : 'center'
}, {
header : "操作员",
id : 'content',
dataIndex : 'secOperator.logonName',
// width : 150,
align : 'center'
}])
this.gridMain = new Ext.grid.GridPanel({
store : this.ds,
cm : this.cm,
sm : this.sm,
stripeRows : true,
height : 300,
width : 500,
loadMask : true,
bbar : new Ext.PagingToolbar({
pageSize : 20,
store : this.ds,
displayInfo : true,
// displayMsg: 'From {0} to {1} ,
// total:
// {2}',
emptyMsg : "No record"
}),
tbar : new Ext.Toolbar({
items : [this.ButtonOK]
})
});
this.windowRef = new Ext.Window({
//layout : 'fit',
modal : true,
height : 300,
width : 500,
title : '请选择一列值',
//closeAction : 'hide',
iconCls : 'images/add.png',
// plain : true,
items : this.gridMain
});
this.ButtonOK.on('click', this.ButtonOK_Click, this, {
preventDefault : true
});
},
ButtonOK_Click : function() {
var selectedItems = this.gridMain.selModel.selections.keys;
if (selectedItems.length == 0) {
Ext.MessageBox.alert("请选择一条记录");
} else {
var selectedRow = this.gridMain.getSelectionModel().getSelected();
this.windowRef.close();
this.setValue(selectedRow.get('contentId'));
var text = selectedRow.get('contentId');
Ext.form.ShiftDefRefContentTab.superclass.setValue.call(this, text);
}
},
onTriggerClick : function() {
this.ds.load({
params : {
start : 0,
limit : 15
}
});
this.windowRef.show();
}
});
//应用扩展的TriggerField
var EsgTab_id = new Ext.form.ShiftDefRefEsgTab();
var ContentTab_id = new Ext.form.ShiftDefRefContentTab();
var EsgTimeSpanTab_id = new Ext.form.ShiftDefRefEsgTimeSpan();
function doAddEsg() {
var addSimpleForm = new Ext.FormPanel({
labelWidth : 75,
frame : true,
title : '节目单',
bodyStyle : 'padding:5px 5px 0',
width : 500,
layoutConfig : {
columns : 3,
align : 'top'
},
defaults : {
width : 200
},
defaultType : 'textfield',
// items : [{
// xtype : 'textfield',
// fieldLabel : '包名称',
// name : 'name',
// anchor : '75%'
// },EsgTimeSpanTab_id],
items : [EsgTimeSpanTab_id, EsgTab_id, ContentTab_id],
buttons : [{
text : '添加',
type : 'submit',
handler : function() {
addSimpleForm.getForm().doAction('submit', {
url : 'doAddEsgRel.action',
method : 'post',
params : {
esgTabId : addSimpleForm.getForm()
.findField('esgId').getValue(),
contentId : addSimpleForm.getForm()
.findField('contentId').getValue(),
esgTimespanId : addSimpleForm.getForm()
.findField('esgTimespanId').getValue()
},
success : function(result) {
win.close();
Ext.MessageBox.alert("成功");
esgGrid.store.reload({
callback : function() {
esgGrid.getView().refresh();
}
});
},
failure : function() {
Ext.MessageBox.alert("失败");
}
});
}
}, {
text : '退出',
handler : function() {
win.close();
}
}]
})
var win = new Ext.Window({
title : ' 添加 ',
height : 150,
width : 400,
resizable : false,
frame : true,
autoHeight : true,
modal : true,
items : [addSimpleForm]
})
win.show()
}
temp.PNG(第一次弹出的form中可以看到的图片 中有TriggerField)
temp-1.PNG(第二次点击”退出“ 弹出的form中可以看到的图片 中没有TriggerField在表单中)
请大侠给我看看 非常感谢