esyui使用心得

dialog 关闭之前调用方法

导致点击确定和取消都会刷新页面,使用 dlgAddPlanType.dialog('close',true);   给close方法传true则在关闭前跳过onBeforeClose(跳过刷新页面的方法)
 {
                text: '取消',
                iconCls: 'icon-no',
                handler: function () {
                    dlgAddPlanType.dialog('close',true);
                }
            }],
            onBeforeClose: function () {
                parent.$.modalDialog.getAllEmergencyList = getAllEmergencyList();
            }

//自定义combotree 校验方法

validType:['nullNumberPhone[names]','nullUserName[userName]']

editor: { type: 'combotree',options: {
                        required: true,
                        data:treeData,
                        validType:['nullNumberPhone[names]','nullUserName[userName]'],
                    }
                },



 $.extend($.fn.validatebox.defaults.rules, {
        nullNumberPhone : {
            validator: function(value, param){
                if(param[0] !=""){
                    return false;
                }
                else return true;
            },
            message: '选择的用户当中存在没有配置手机号的用户!!!'
        },
        nullUserName :{
            validator: function(value, param){
                if(param[0] ==""){
                    return false;
                }
                else return true;
            },
            message: '选择的用户为空,请重新选择!'
        }
    });

结束编辑的时候让combotree的value更新为文本

(解决combotree结束编辑的时候显示value而不是文本)
 onAfterEdit: function (rowIndex, rowData, changes) {
            //endEdit该方法触发此事件
            editRow = undefined;
            //更新行数据为文本
            $("#message_datagridOne").datagrid('updateRow',{index:rowIndex,row:{UserName:userName}});
            $("#message_datagridOne").datagrid('updateRow',{index:rowIndex,row:{UserPhone:userNumbers}});
        }

EasyUI实现第二层弹出框的方法

https://www.xp.cn/b.php/109297.html

easyui 子页面提交之后调用父页面方法

创建对话框页面,并调用子页面方法提交成功之后返回success值并调用父页面方法
function createTemplate() {
        $.dlgtemplate = parent.$.modalDialog({
            iconCls: 'ext-icon-note_add',
            title: 'xxx',
            width: 1300,
            height: 800,
            resizable: false,
            href: global.basePath + '/emergencyplan/planscheme/createtemplate.do',
            buttons: [{
                text: '确定',
                iconCls: 'icon-ok',
                handler: function () {
                    var r =  parent.$.modalDialog.saveGridData();
                    if (r.success) {
                        $.dlgtemplate.dialog('close');
                       // window.location.reload();
                        getRecord(r.emergencyTypeId);
                    }

                }
            }, {
                text: '取消',
                iconCls: 'icon-no',
                handler: function () {

                    var msg = '详细信息?';
                    $.ibpConfirm('提示', msg, function () {
                        parent.$.modalDialog.cancelGridData();

                        $.dlgtemplate.dialog('close');
                    });

                }
            }]
        });
    }
parent.$.modalDialog.saveGridData = function () {
    var selectedSchemeType = $("#schemeType").combobox("getValue");
    var _r = {
        success: false,
        emergencyTypeId:selectedSchemeType,
    };
    return _r;
    }

combotree模糊搜索叶子节点

  query:function(q) {
            function reSearchFun(t, nodes, searchText) {
                for (var i = 0; i < nodes.length; i++) {

                    var node = nodes[i];
                    if( node!=t.tree('getRoot')) {
                        $(node.target).hide();
                    }
                    if (node.children) {
                        reSearchFun(t, node.children, searchText);
                    } else {
                        var nodetemp = node;

                        if (node.text.indexOf(searchText) >= 0) {
                            var nodetemp = node;

                            while( nodetemp!=t.tree('getRoot')) {
                                $(nodetemp.target).show();
                                nodetemp=t.tree('getParent', nodetemp.target);
                            }

                            t.tree('expandTo', node.target);


                        }
                    }
                }
            }

            //支持最后一个字符的搜索
            var searchTextArray = q.split(',');
            var searchText = searchTextArray[searchTextArray.length - 1];
            var t = $(this).combotree('tree');
            var nodes = t.tree('getChildren');
            reSearchFun(t, nodes, searchText);
            //t.tree('expandAll');
            /*for(var i=0;i<nodes.length; i++){
                var node = nodes[i];
                if(node.children){
                    reSearchFun(node, searchText);
                }else{
                    if(node.text.indexOf(searchText) >= 0){
                        $(node.target).show();
                    } else {
                        $(node.target).hide();
                    }
                }
            }*/
            var opts = $(this).combotree('options');
            if (!opts.hasSetEvents) {
                opts.hasSetEvents = true;
                var onShowPanel = opts.onShowPanel;
                opts.onShowPanel = function () {
                    var nodes = t.tree('getChildren');
                    for (var i = 0; i < nodes.length; i++) {
                        $(nodes[i].target).show();
                    }
                    onShowPanel.call(this);
                };
                $(this).combo('options').onShowPanel = opts.onShowPanel;
            }
        }

新添加的行导致序号混乱

点击行的时候 给当前行赋全局变量,删除时(点确定在删除全局变量存的行号)

onClickCell:function(index,field){
            deleteRow =index;
        },
function clickBtnDelete(index){
    if(index !=undefined) {
        datagridOne.datagrid("endEdit", editRow);
        $.messager.confirm("提示", "你确定要删除该行吗?", function (r) {
            if (r) {
                datagridOne.datagrid("deleteRow", deleteRow);
            }
        });
    }
    editRow = undefined;

};

combotree 数据匹配

addMessage = function(){
    //添加时先判断是否有开启编辑的行,如果有则把开户编辑的那行结束编辑
    if (editRow != undefined) {
        datagridOne.datagrid("endEdit", editRow);
    }
    //以下用于处理用户只填写了用户名又去新增一行导致原来的行数据丢失,此时禁止再次新增行
    var rows=$('#message_datagridOne').datagrid('getRows');
    if(rows[0] && rows[0].emergencyMessagePhoneList ==undefined){
        if(rows[0].UserName == undefined){
            $.messager.show({title:'提示',msg:'请确保填写信息正确!'});
            return;
        }
    }
    //添加时如果没有正在编辑的行,则在datagrid的第一行插入一行
    if (editRow == undefined) {
        datagridOne.datagrid("insertRow", {
            index: 0, // index start with 0
            row: {}
        });
        //将新插入的那一行开户编辑状态
        datagridOne.datagrid("beginEdit", 0);
        //给当前编辑的行赋值
        editRow = 0;
        $(".tableCls span.textbox-invalid.combo").css("height","91px");
        $(".tableCls span.textbox-addon-right").css({display:"none"});
    }
    loadcombotreeData();
};

function loadcombotreeData(){
   ....................................//省略
            onLoadSuccess: function(node, data) {
                var rows=$('#message_datagridOne').datagrid('getRows');
                var arr = [];
                var node = combotree.combotree("tree").tree("getRoot");
                cnode = combotree.combotree("tree").tree("getChildren",node.target);
                for (var i = 0, l = cnode.length; i < l; ++i) {
                    var node = cnode[i];
                    node = combotree.combotree("tree").tree("getChildren",node.target);
                    if(node.length==0){
                        if(cnode[i].attributes.userName !=undefined){
                            //console.info(JSON.stringify(rows[editRow]));
                            //遍历行数据进行匹配
                                if(rows[editRow] != undefined && rows[editRow].UserName == undefined){
                                    var row = rows[editRow];
                                    if(row.emergencyMessagePhoneList != undefined && row.emergencyMessagePhoneList.length >0){
                                        for (var j = 0; j< row.emergencyMessagePhoneList.length; j++) {
                                            var temp = row.emergencyMessagePhoneList[j].name;
                                          //  console.info(JSON.stringify("后台名字"+temp));
                                            if(cnode[i].attributes.userName ==temp){
                                                arr.push(cnode[i].id);
                                            }

                                        }
                                    }
                                } else {
                                
                        }
                  
                    }
                }
                console.info(arr);
                combotree.combotree("setValues",arr);

            }
        });
    }, 10);
};


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值