EasyUI使用之鼠标双击事件

时间:2023-03-08 22:52:47
EasyUI使用之鼠标双击事件

easyui鼠标双击事件,使用 onDblClickRow(index, row) 事件,在用户双击一行的时候触发,参数包括:

  • index:点击的行的索引值,该索引值从0开始。
  • row:对应于点击行的记录。
$("#wu-datagrid-news").datagrid({
loadFilter: pagerFilter,//分页
rownumbers: true,//如果为true,则显示一个行号列。
singleSelect: false,//如果为true,则只允许选择一行。
multiSort: true,//定义是否允许多列排序。
fitColumns: true,//真正的自动展开/收缩列的大小,以适应网格的宽度,防止水平滚动。
fit: true,//自适应
  idField: 'id',//指明哪一个字段是标识字段
loadMsg: 'Processing, please wait …',//在从远程站点加载数据的时候显示提示消息。
pagination: true, //如果为true,则在DataGrid控件底部显示分页工具栏。

columns: [[{
field: 'id', //列字段名称
width: '100', //列的宽度。如果没有定义,宽度将自动扩充以适应其内容。
title: 'ID', //列标题文本
checkbox: true //复选框,该复选框列固定宽度。
}, {
field: 'trainTitle',
title: '标题',
width: '300',
align: 'center'
}, {
field: 'trainAuthor',
title: '作者',
width: '100',
align: 'center'
}, {
field: 'trainBody',
title: '正文',
width: '500',
align: 'center'
}, {
field: 'imgPath',
title: '图片',
width: '80',
align: 'center',
hidden:'true'//此列隐藏
}, {
field: 'createTime',
title: '创建时间',
width: '150',
align: 'center'
}
]],
onDblClickRow:function(rowIndex){//鼠标双击事件
$("#wu-datagrid-news").datagrid("selectRow",rowIndex);//选中此行
var currentRow = $("#wu-datagrid-news").datagrid("getSelected");//获得选中行的信息 //弹出框赋值
$("#newsTitle").val(currentRow["trainTitle"]);
$("#newsAuthor").val(currentRow["trainAuthor"]);
$("#newImg").attr('src','');
$("#newImg").attr('src',httpurl+'/'+currentRow["imgPath"]);
$("#newsBody").val(currentRow["trainBody"]);
$("#imgPath").hide();
$('#wu-dialog-news').dialog({//弹出框
closed: false,
modal: true,
title: "查看信息",
buttons: [{
text: '确定',
iconCls: 'icon-ok',
handler: function () {
$('#wu-dialog-news').dialog('close');
}
}]
});
}
});