老外的例子,两个步骤
1.在uniForm的uniEvent属性中写入以下代码:
function window.OnBeforeInit(sender)
{
Ext.apply (sender, {
tools: [{
type: 'pin',
tooltip: 'tooltip of pin',
handler: function(event, toolEl, panel){
ajaxRequest(sender, 'tool', [ 'btn=pin' ] );
}
},{
type: 'refresh',
tooltip: 'tooltip of refresh',
handler: function(event, toolEl, panel){
ajaxRequest(sender, 'tool', [ 'btn=refresh' ] );
}
},{
type: 'search',
tooltip: 'tooltip of search',
handler: function(event, toolEl, panel){
ajaxRequest(sender, 'tool', [ 'btn=search' ] );
}
},{
type: 'save',
tooltip: 'tooltip of save',
handler: function(event, toolEl, panel){
ajaxRequest(sender, 'tool', [ 'btn=save' ] );
}
}]
});
}
2.在uniForm的AjaxEven事件中写入以下代码:
procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string;
Params: TStrings);
begin
if EventName='tool' then
ShowMessage('Button '+Params.Values['btn']+' pressed');
//解释一下这里可以根据Params.Values['btn']的值来确定是哪一个button产生的事件
end;
效果不错: