Ext视图里按钮JS总结

2024-06-03 23:38
文章标签 总结 js 视图 按钮 ext

本文主要是介绍Ext视图里按钮JS总结,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.打开文档:

function(){	var records = grid.getSelectedRecords();	if(records.length > 0){		var id = records[0].get('ID');	MixkyApp.desktop.openDocument('moduleName.docName');	}
}


其他写法:

MixkyApp.desktop.openDocument('moduleName.docName', id,undefined, {
	openerId : panel.getId()
});


2.如果需要获取视图里的字段的值:

records[0].get('fieldName');

3.提示消息:

MixkyApp.showInfoMessage("提示内容");

4.新增:

function(){
	MixkyApp.desktop.openDocument('moduleName.docName');
}

其他写法:

MixkyApp.desktop.openDocument('moduleName.docName', 0);


6.批量处理按钮:

function () {var records = grid.getSelectedRecords();if (records.length > 0) {Ext.Msg.confirm('系统提示','确定要XX选中的XX吗?',function(btn){if(btn=='yes'){var ids = [];for (var i = 0; i < records.length; i++) {ids[i] = records[i].get('ID');}XXXDirect.XXX(ids,function(r,e) {if(r && r.success) {MixkyApp.showInfoMessage('XXX!');grid.getStore().load();} else {MixkyApp.showErrorMessage('操作失败!' + r.message);}}); }});}
}


7.Excel导入:

function() {function openUpload(type,id){ types = type;  uploadid = id; winUpload.show(); }  var formUpload = new Ext.form.FormPanel({ baseCls: 'x-plain', labelWidth: 80, fileUpload:true, defaultType: 'textfield', items: [{  xtype: 'textfield', fieldLabel: '文 件', name: 'upload', inputType: 'file', allowBlank: false, blankText: '请上传文件', anchor: '90%'  }]  });  var winUpload = new Ext.Window({ title: 'Excel导入', width: 400,  height:200,  minWidth: 300, minHeight: 100, layout: 'fit', plain:true,  bodyStyle:'padding:5px;',buttonAlign:'center', items: formUpload, buttons: [{  text: '导入',  handler: function() { if(formUpload.form.isValid()){ Ext.MessageBox.show({ title: 'Please wait', msg: 'Importting...', progressText: '', width:300,  progress:true, closable:false, animEl: 'loding'});  formUpload.getForm().submit({ url:'plugin/kd/excel.import.do?type=1', success: function(form, action){ Ext.Msg.alert('成功','导入成功.'); winUpload.hide(); },  failure: function(form, action){console.log(action);var res = eval( "(" + action.response.responseText + ")" );Ext.Msg.alert('Error', "导入失败:"+res.message);winUpload.hide();}  }) }  }  },{  text: '取 消',  handler:function(){winUpload.hide();} }]  });openUpload(); 
}


8.Excel导出:

function() {panel.exportToExcel();
}

9.弹窗:

MixkyApp.desktop.openUrlWithWindow('XXX', 'XXX.do?ids='+ids+'&gridId='+gridId,{title:'XXX',width : 350,height : 150,resizable : true,plain: true,modal:true,maximized:false,iconCls:'icon-sys-create',maximizable : true,minimizable : false,
}); 


10.确认弹窗(删除时的确认):

function(){Ext.MessageBox.confirm('操作确认', '该操作将XXX,您确定吗?', function(btn){if(btn == 'yes'){var records = getSelectedRecords();if(records.length > 0){var id = records[0].get('ID');id=parseInt(id);XXXDirect.deleteDocument('modulename.docname', id, function(r,e){if(r && r.success){panel.refresh();} else {MixkyApp.showErrorMessage('操作失败,' + r.message);}});}}});
}


11.附件下载:

function(){var records = grid.getSelectedRecords();if(records.length > 0){var url = records[0].get('F_URL');if(url != "") {window.open(url);} else {MixkyApp.showInfoMessage('该信息尚无所选类型附件');}}
}


12.导出视图里未显示的字段:

function () {var selects = grid.getSelectionModel().getSelections();var ids = [];if (selects != null && selects.length > 0) {for (var i = 0; i < selects.length; i++) {ids[i] = selects[i].get("ID");}}var tableAll = false;var titles = [{name:'ID',key:'ID',format:'',width:'3000'},...,{name:'XXX',key:'F_XXX',format:'',width:'9000'}];var index;var array = new Array();for(index in titles) {var json =JSON.stringify(titles[index]);//对象转为JSONarray.push(json);}var excelParams = Ext.apply({},grid.getStore().baseParams);Ext.apply(excelParams,{ids: ids,titles:array, panelTitle: panel.title,tableAll:tableAll});excelParams.params = Ext.util.JSON.encode(excelParams.params);MixkyApp.showInfoMessage("表单生成需较长时间,请耐心等待");
	location.href = '/manage/downXXX.do?' + Ext.urlEncode(excelParams);
}


13.信息变更按钮:

	
function () {var viewPanel = panel;var records = grid.getSelectedRecords();if(records.length > 0){	//获取所需内容var memId = records[0].get('ID');	var memName = records[0].get('F_NAME');//弹窗选择变更内容字段showFormWin(records[0],viewPanel);} else {return;}//弹出窗口function showFormWin(record,viewPanel) {var memId = record.get('ID');var memName = record.get('F_NAME');//初始化标签中的Ext:Qtip属性。Ext.QuickTips.init();Ext.form.Field.prototype.msgTarget = 'side';//内容inputvar txtoldcontent = new Ext.form.TextArea({width: 280,allowBlank: true,maxLength: 100,//name: 'username',fieldLabel: '旧内容',blankText: '',maxLengthText: '内容不能超过100个字符'});var txtnewcontent = new Ext.form.TextArea({width: 280,allowBlank: false,maxLength: 100,//name: 'username',fieldLabel: '新内容',blankText: '请输入新内容',maxLengthText: '内容不能超过100个字符'});//----------------------下拉列表开始----------------------////创建数据源[数组数据源]var combostore = new Ext.data.ArrayStore({fields: ['updateType', 'name'],data: [['company', 'XXX'], ['major', 'XXX']]});//创建Comboboxvar combobox = new Ext.form.ComboBox({width: 280,fieldLabel: '变更属性',store: combostore,displayField: 'name',valueField: 'updateType',triggerAction: 'all',emptyText: '请选择...',allowBlank: false,blankText: '请选择属性',editable: false,mode: 'local'});//Combobox获取值combobox.on('select', function () {//alert(combobox.getValue());var oldContent = "";var fieldType = combobox.getValue();if(fieldType == "company") {oldContent = record.get('F_COMPANY');} else if(fieldType == "major") {oldContent = record.get('F_MAJOR');}txtoldcontent.setValue(oldContent);})//----------------------下拉列表结束----------------------////----------------------按钮开始----------------------//function updateMemInfo() {var updateType = combobox.getValue();var newContent = txtnewcontent.getRawValue();if(updateType && updateType!='' && newContent && newContent!='') {XXXDirect.updateXXXInfo(memId,updateType,newContent,function(r,e) {if(r && r.success) {MixkyApp.showInfoMessage('信息更新成功!');viewPanel.refresh();Ext.getCmp('updateXXXWin').close();} else {MixkyApp.showErrorMessage('操作失败:' + r.message);}} );} else {return;}}//提交按钮处理方法var btnsubmitclick = function () {updateMemInfo();}//提交按钮var btnsubmit = new Ext.Button({text: '提交',handler: btnsubmitclick});//----------------------按钮结束----------------------////表单var form = new Ext.form.FormPanel({frame: true,height: 204,style: 'margin:10px',items: [combobox, txtoldcontent, txtnewcontent],buttons: [btnsubmit]});//窗体var win = new Ext.Window({id:'updateXXXWin',title: '信息更新 - ' + memName,width: 447,height: 264,html: '',resizable: true,modal: true,closable: true,closeAction: 'close', maximizable: true,minimizable: true,buttonAlign: 'center',items: form});win.show();}
}

14.弹窗视图(表格类型):

<%@ page contentType="text/html; charset=utf-8"%>
<%String panelid = request.getParameter("panelid");String termname = request.getParameter("termname");String termid = request.getParameter("termid");
%>
<script language='javascript'>
Ext.onReady(function(){var panelid = '<%=panelid%>';var panel = Ext.getCmp(panelid);// 存储字段var fields = [{name:'id', mapping:'id'},{name:'f_branch_name', mapping:'f_branch_name'},{name:'f_branch_id', mapping:'f_branch_id'},{name:'f_branch_term', mapping:'f_branch_term'}];// 列表字段var columns = [new Ext.grid.CheckboxSelectionModel(),{id : 'id',dataIndex : 'id',width:70,header : 'XXX'},{id : 'f_branch_name',dataIndex : 'f_branch_name',header : 'XXX',width:120},{id : 'f_branch_id',dataIndex : 'f_branch_id',width:120,header : 'XXX'},{id : 'f_branch_term',dataIndex : 'f_branch_term',header : 'XXX'}];// 数据访问var store = new Ext.data.DirectStore({directFn : BranchTermListDirect.getBranchTermList,root : 'results',totalProperty : 'totals',idProperty : 'id',sortInfo: {field:'id', direction: 'ASC'},fields:fields});// 功能条var btnRefresh = new Ext.Action({text : '刷新',iconCls : 'icon-sys-refresh',handler : function(){panel.refresh();}});var btnSave = new Ext.Action({text : '保存',iconCls : 'icon-sys-save',handler : function(){panel.save();}});var tools = [btnSave, '-', btnRefresh];// 表格对象var grid = new Ext.grid.GridPanel({region : 'center',border : false,sm:new Ext.grid.CheckboxSelectionModel(),columns : columns,autoExpandColumn:'f_branch_name',enableHdMenu:false,enableColumnMove:false,store : store,tbar : tools,contextMenu : new Ext.menu.Menu({items:tools}),listeners : {'rowcontextmenu' : function(g, rowIndex, e){g.getSelectionModel().selectRow(rowIndex);g.contextMenu.showAt(e.getXY());},'rowdblclick' : function(g, rowIndex, e){btnEdit.execute();}}});// 刷新panel.refresh = function(){store.reload();}// 保存属性修改panel.save = function(){var records = grid.getSelectionModel().getSelections();	if(records.length > 0){	var ids = '';	var names = '';for(var i=0;i<records.length;i++){ids += records[i].data.id+',';	names += records[i].data.f_branch_name+',';}BranchTermListDirect.addBranchToOrg(ids,names,'<%=termname%>','<%=termid%>', function(result, e){if(result && result.success){MixkyApp.showInfoMessage('数据以保存','提示信息');}else{MixkyApp.showErrorMessage('保存数据出现错误!', '错误提示');}});}};panel.add(grid);panel.doLayout();panel.refresh();
});
</script>

15.输入提示框:

function(){Ext.Msg.prompt('添加XXX', '请输入XXX:', function(btn, text){if (btn == 'ok' && text != ''){XXXDirect.SaveDataToDictionary({'dictionary':'mkNotifyTag','f_caption':text,'f_name':text,'state':'add'}, function(result, e){if(result && result.success){panel.refresh();}else{MixkyApp.showDirectActionFail("添加【" + text + "】XXX失败", result, e);}})}});
}

16.获取修改的数据:

store.getModifiedRecords();
需要提交

17.删除:

panel.removeRecord();

18.上移下移:

panel.moveUp();
panel.moveDown();

19.群发:

function(){
var selects = grid.getSelectionModel().getSelections();var ids = [];var isAll=false;if (selects != null && selects.length > 0) {var emptyTel='';for (var i = 0; i < selects.length; i++) {ids[i] = selects[i].get("F_TEL");if(ids[i]==''){emptyTel+=selects[i].get("F_NAME");emptyTel+='、';}}emptyTel=emptyTel.substring(0,emptyTel.length-1);if(emptyTel!=''){MixkyApp.showInfoMessage(emptyTel+'XXX是空的','提示信息');if(selects.length=1){return;}}MixkyApp.desktop.openUrlWithWindow('sendMsgUtil', 'sendMsg.do?tels='+ids+'&isAll=false',{title:'自定义XXX',width : 500,height : 300,resizable : true,plain: true,modal:true,maximized:false,iconCls:'icon-sys-create',maximizable : true,minimizable : false,});	}else{Ext.MessageBox.confirm('操作确认', '您未选中数据,继续将给所有人XX,您继续吗?', function(btn) {if (btn == 'yes') {		MixkyApp.desktop.openUrlWithWindow('sendMsgUtil', 'sendMsg.do?tels='+ids+'&isAll=true',{title:'自定义XXX',width : 500,height : 300,resizable : true,plain: true,modal:true,maximized:false,iconCls:'icon-sys-create',maximizable : true,minimizable : false,});		 }});}}


这篇关于Ext视图里按钮JS总结的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1028439

相关文章

HarmonyOS学习(七)——UI(五)常用布局总结

自适应布局 1.1、线性布局(LinearLayout) 通过线性容器Row和Column实现线性布局。Column容器内的子组件按照垂直方向排列,Row组件中的子组件按照水平方向排列。 属性说明space通过space参数设置主轴上子组件的间距,达到各子组件在排列上的等间距效果alignItems设置子组件在交叉轴上的对齐方式,且在各类尺寸屏幕上表现一致,其中交叉轴为垂直时,取值为Vert

JS常用组件收集

收集了一些平时遇到的前端比较优秀的组件,方便以后开发的时候查找!!! 函数工具: Lodash 页面固定: stickUp、jQuery.Pin 轮播: unslider、swiper 开关: switch 复选框: icheck 气泡: grumble 隐藏元素: Headroom

学习hash总结

2014/1/29/   最近刚开始学hash,名字很陌生,但是hash的思想却很熟悉,以前早就做过此类的题,但是不知道这就是hash思想而已,说白了hash就是一个映射,往往灵活利用数组的下标来实现算法,hash的作用:1、判重;2、统计次数;

在JS中的设计模式的单例模式、策略模式、代理模式、原型模式浅讲

1. 单例模式(Singleton Pattern) 确保一个类只有一个实例,并提供一个全局访问点。 示例代码: class Singleton {constructor() {if (Singleton.instance) {return Singleton.instance;}Singleton.instance = this;this.data = [];}addData(value)

git使用的说明总结

Git使用说明 下载安装(下载地址) macOS: Git - Downloading macOS Windows: Git - Downloading Windows Linux/Unix: Git (git-scm.com) 创建新仓库 本地创建新仓库:创建新文件夹,进入文件夹目录,执行指令 git init ,用以创建新的git 克隆仓库 执行指令用以创建一个本地仓库的

二分最大匹配总结

HDU 2444  黑白染色 ,二分图判定 const int maxn = 208 ;vector<int> g[maxn] ;int n ;bool vis[maxn] ;int match[maxn] ;;int color[maxn] ;int setcolor(int u , int c){color[u] = c ;for(vector<int>::iter

整数Hash散列总结

方法:    step1  :线性探测  step2 散列   当 h(k)位置已经存储有元素的时候,依次探查(h(k)+i) mod S, i=1,2,3…,直到找到空的存储单元为止。其中,S为 数组长度。 HDU 1496   a*x1^2+b*x2^2+c*x3^2+d*x4^2=0 。 x在 [-100,100] 解的个数  const int MaxN = 3000

状态dp总结

zoj 3631  N 个数中选若干数和(只能选一次)<=M 的最大值 const int Max_N = 38 ;int a[1<<16] , b[1<<16] , x[Max_N] , e[Max_N] ;void GetNum(int g[] , int n , int s[] , int &m){ int i , j , t ;m = 0 ;for(i = 0 ;

Node.js学习记录(二)

目录 一、express 1、初识express 2、安装express 3、创建并启动web服务器 4、监听 GET&POST 请求、响应内容给客户端 5、获取URL中携带的查询参数 6、获取URL中动态参数 7、静态资源托管 二、工具nodemon 三、express路由 1、express中路由 2、路由的匹配 3、路由模块化 4、路由模块添加前缀 四、中间件

EasyPlayer.js网页H5 Web js播放器能力合集

最近遇到一个需求,要求做一款播放器,发现能力上跟EasyPlayer.js基本一致,满足要求: 需求 功性能 分类 需求描述 功能 预览 分屏模式 单分屏(单屏/全屏) 多分屏(2*2) 多分屏(3*3) 多分屏(4*4) 播放控制 播放(单个或全部) 暂停(暂停时展示最后一帧画面) 停止(单个或全部) 声音控制(开关/音量调节) 主辅码流切换 辅助功能 屏