easyui datagrid 单击删除时阻止时间冒泡

来源:互联网 发布:steam动态壁纸软件mac 编辑:程序博客网 时间:2024/06/13 18:17

最近用easyui做东西,一次在datagrid中做删除功能,追简单的就是formatter中return出一个<a>删除</a>,但是在最后突然发现单击一下删除按钮会选中,再次单击一下就会撤销选中,突然就像起了事件冒泡所以做了一下总结。

以下是具体代码。

/*

 * 阻止事件冒泡
 * */
function preventBubble(){
if($.browser.mozilla){
                 var $E = function(){var c=$E.caller; while(c.caller)c=c.caller; return c.arguments[0]};
                  __defineGetter__("event", $E);
        }

if (window.event) {
event.cancelBubble = true; 
}else if (evt){
event.stopPropagation();

}

//打开dialog
function openShowDialog(status,rowIndex){
preventBubble();
if($.trim(status)!=''){
$("#status"+status).attr('checked',true);
}
if($.trim(rowIndex)!=''){
$("#serialNumManageGrid").datagrid('selectRow',rowIndex);
}
var getSelect = $("#serialNumManageGrid").datagrid("getSelections");
if(getSelect.length=='0'){
$.messager.alert('提示:','您当前没有选择任何需要操作的记录,请先选择要更改的数据!');
return;
}
$("#editStatusDialog").dialog("open");

//$("#serialNumManageGrid").datagrid('selectRow',rowIndex);
}