Jeecg中Dialog弹出新页面自定义按钮

来源:互联网 发布:第三方软件测试 c语言 编辑:程序博客网 时间:2024/06/05 20:17

关于Jeecg中的弹出层Dialog

在Jeecg中使用到的Jialog实际上是使用的lghDialog组件具体可以参考lghDialog的API:http://www.lhgdialog.com/demo/

function createNewWindow(title, addurl,width,height) {    width = width?width:700;    height = height?height:400;    if(width=="100%" || height=="100%"){        try {            width = window.top.document.body.offsetWidth;            height =window.top.document.body.offsetHeight-100;        } catch (e) {            width = window.innerWidth;            height = window.innerHeight-100;        }    }    $.dialog({        content: 'url:'+addurl,        lock : true,        width:width,        height:height,        title:title,        opacity : 0.3,        cache:false,        ok: function(){            iframe = this.iframe.contentWindow;            saveObj();//已封装过的保存方法            return false;        },        cancelVal: '关闭',        cancel: true,        button:[{            name: '保存',             callback: function(){                iframe = this.iframe.contentWindow;//获取弹出层的iframe                saveParam();//自定义保存数据方法                return false;//阻止页面关闭(默认为true不关闭)            }        }]    }).zindex();}/** * 自定义保存数据方法 * @param url * @param gridname */function saveParam() {    $("#formobj", iframe.document).form('submit', {        //url : url,        onSubmit : function() {        },        success : function(r) {            msgdialog('操作成功!','success');        },        error : function(r) {            msgdialog('操作异常!','error');        }    });//UsersForm为Form表单id,提交表单}/** * 操作结果提示语 * @param content:提示内容 * @param type:图标类型 */function msgdialog(content,type){    $.dialog({        content: content,        title:'提示信息',        icon: type+'.gif',        titleIcon: 'lhgcore.gif',        width:136,        height:80,        top: '98%',        left:'98%',        fixed: true    });}
  • Dialog参数简介

  • content:弹窗内容—>1. 字符串(str)、2.使用iframe方式加载单独的内容页(url)

  • lock:锁屏(true or false)

  • width :宽度

  • height:高度

  • title:标题内容

  • opacity:透明度

  • ok/cancel:确定/取消按钮(框架已封装照用即可)


[button]:自定义按钮

  • name 按钮名称

  • callback 回调函数、返回false将阻止对话框关闭,回调函数内可以实现自己想在点击按钮时所做的操作

  • formobj 在saveParam()中formobj为子页面的formid、得到子页面的iframe获取需要保存数据的document,然后利用form表单submit即可

后记

Jeecg中有很多东西是框架封装好的一般情况下是够用的,在有特殊需求的时候发现其本身不够用了, 由于框架本身js经过封装还有iframe层级关系比较复杂,重写时建议先仔细研究在框架本身的基础上进行小的修改比较省时省力,也可以去社区寻找帮助。 —— [ Jeecg社区 ]


原创粉丝点击