queryButtonHandler : function() {
var queryWindow = Ext.create(
'foodmis.view.EmbranchmentQueryWindow', {
title : '查询',
id : 'EmbranchmentQueryWindow'
}).show();
// var formPanel =
// queryWindow.getComponent("FoodEmbranchmentQueryForm");
// formPanel.loadRecord(lastSelected);
},
updateButtonHandler : function() {
var sm = this.getSelectionModel();
var lastSelected = sm.getLastSelected();
if (lastSelected != null) {
var editorWindow = Ext.create(
'foodmis.view.EmbranchmentEditorWindow', {
title : '修改',
id : 'EmbranchmentEditorWindow'
}).show();
var formPanel = editorWindow
.getComponent("EmbranchmentEditorForm");
formPanel.loadRecord(lastSelected);
} else {
Ext.MessageBox.alert("注意", "请选择一个要修改的数据!");
}
},
addButtonHandler : function() {
var addWindow = Ext.create(
'foodmis.view.EmbranchmentAddWindow', {
title : '添加',
id : 'EmbranchmentAddWindow'
}).show();
var formPanel = addWindow
.getComponent("EmbranchmentAddForm");
var newModel = Ext.ModelManager.create({},
'foodmis.model.EmbranchmentModel');
formPanel.loadRecord(newModel);
},
deleteButtonHandler : function() {
var sm = this.getSelectionModel();
var lastSelected = sm.getLastSelected();
var gridPanel = Ext.getCmp('EmbranchmentGridPanel');
var gridStore = gridPanel.getStore();
if (lastSelected != null) {
Ext.Ajax
.request({
url : 'http://localhost:8080/admin-web/jsonservice/foodEmbranchmentService.json',
method : 'POST',
jsonData : {
jsonrpc : "2.0",
id : 10,
method : "delete",
parameters : [ lastSelected
.get("embranchmentId") ]
},
success : function(result, request) {
gridStore.remove(lastSelected);
Ext.MessageBox.alert("提示",
result.responseText);
},
failure : function(form, action) {
Ext.MessageBox.alert("提示", "请求失败!");
}
});
} else {
Ext.MessageBox.alert("注意", "请选择一个要删除的数据!");
}
},
refreshButtonHandler : function() {
this.store.reload();
// gridPanel.getView().refresh();
}
|
//Ext.ux.ImageButton.js文件源码
Ext.namespace('Ext.ux');
Ext.ux.ImageButton = function(cfg) {
Ext.ux.ImageButton.superclass.constructor.call(this, cfg);
};
Ext.extend(Ext.ux.ImageButton, Ext.Button, {
onRender : function(ct, position) {
this.disabledImgPath = this.disabledImgPath || this.imgPath;
var tplHTML = '<div><img src="{imgPath}" border="0" width="{imgWidth}" height="{imgHeight}" alt="{tooltip}" style="cursor: {cursor};"/> {imgText:htmlEncode}<br/><br/></div>';
var tpl = new Ext.Template(tplHTML);
var btn, targs = {
imgPath : this.disabled ? this.disabledImgPath : this.imgPath,
imgWidth : this.imgWidth || "",
imgHeight : this.imgHeight || "",
imgText : this.text || "",
cursor : this.disabled ? "default" : "pointer",
tooltip : this.tooltip || ""
};
btn = tpl.append(ct, targs, true);
btn.on("click", this.onClick, this);
if (this.cls) {
btn.addClass(this.cls);
}
this.el = btn;
if (this.hidden) {
this.hide();
}
},
disable : function(newImgPath) {
var replaceImgPath = newImgPath || this.disabledImgPath;
if (replaceImgPath)
this.el.dom.firstChild.src = replaceImgPath;
this.disabled = true;
},
enable : function(newImgPath) {
var replaceImgPath = newImgPath || this.imgPath;
if (replaceImgPath)
this.el.dom.firstChild.src = replaceImgPath;
this.disabled = false;
}
});
Ext.reg('imagebutton', Ext.ux.ImageButton);
},
disable : function(newImgPath) {
var replaceImgPath = newImgPath || this.disabledImgPath;
if (replaceImgPath)
this.el.dom.firstChild.src = replaceImgPath;
this.disabled = true;
},
enable : function(newImgPath) {
var replaceImgPath = newImgPath || this.imgPath;
if (replaceImgPath)
this.el.dom.firstChild.src = replaceImgPath;
this.disabled = false;
}
});
Ext.reg('imagebutton', Ext.ux.ImageButton);
|
//调用方法:
var myImageButton=new Ext.ux.ImageButton({
imgPath : 'images/test.gif,
imgWidth : 60,
imgHeight : 60,
tooltip : 'test',//鼠标放上去的提示
handler : function(btn) {
Ext.MessageBox.alert(''test',''test'');
}
});
|