Created
December 23, 2016 14:35
-
-
Save YeomanYe/9150e4373bf382bd174ef8a5864c9488 to your computer and use it in GitHub Desktop.
EasyUI:updateDialog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 更新会话框 | |
* @param {object/string} arg 设置对象或者url | |
* @param {function} callback 回调函数 | |
*/ | |
function updateDialog(arg,callback){ | |
var option = { | |
//datagrid的Id | |
datagridId: arg.datagridId ? arg.datagridId : "datagrid", | |
//标志后端采取更新操作或者是添加操作的隐藏表单的id | |
backEndFlagId: arg.backEndFlagId ? arg.backEndFlagId : "backEndFlagId", | |
//addDialog的Id | |
addDialogId: arg.addDialogId ? arg.addDialogId : "dialog", | |
//url | |
url: arg.url ? arg.url : arg, | |
//回掉函数,一般情况下执行,数据加载到表单的操作 | |
callback: arg.callback ? arg.callback : callback, | |
}; | |
var update = $("#"+option.datagridId).datagrid("getSelections"); | |
if (!update || update.length >1 || !update.length) { | |
$.messager.alert("提示!","必须而且只能选择一条记录进行修改!","warning"); | |
} else { | |
var ids = $("#"+option.datagridId).datagrid("getChecked"); | |
$("#"+option.addDialogId).dialog("open"); | |
$("#"+option.backEndFlagId).val("update"); | |
$.ajax({ | |
url : option.url + ids[0].id, | |
type : "GET", | |
beforeSend : function () { | |
$.messager.progress({ | |
text : '正在加载中...', | |
}); | |
}, | |
success : function (data, response, status) { | |
$.messager.progress('close'); | |
if (data.flag == "success") { | |
if(typeof callback === "function"){ | |
callback(); | |
} | |
}else{ | |
$.messager.alert('提示!', '未知错误,请重试!', 'warning'); | |
} | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment