美文网首页
easyui使用shift或ctrl多选

easyui使用shift或ctrl多选

作者: 灬冷枫 | 来源:发表于2018-11-29 00:11 被阅读0次

今天在网上找的demo,使用后一直报错,以下为自己修改后的版本。


<body class="easyui-layout" data-options="fit:true,border:true" onkeydown="javascript:keyDown(event);">

<script type="text/javascript">

var KEY = {SHIFT:16,CTRL:17,ALT:18,DOWN:40,RIGHT:39,UP:38,LEFT:37 };

var selectIndexs = {firstSelectRowIndex:0,lastSelectRowIndex:0 };

var inputFlags = {isShiftDown:false,isCtrlDown:false,isAltDown:false };


function MultiSelect(index, row) {

if (index !=selectIndexs.firstSelectRowIndex && !inputFlags.isShiftDown) {

selectIndexs.firstSelectRowIndex = index;

}

if (inputFlags.isShiftDown) {

inputFlags.isShiftDown =false;

$('#orderDataGrid').datagrid('clearSelections');

selectIndexs.lastSelectRowIndex = index;

var tempIndex =0;

if (selectIndexs.firstSelectRowIndex >selectIndexs.lastSelectRowIndex) {

tempIndex =selectIndexs.firstSelectRowIndex;

selectIndexs.firstSelectRowIndex =selectIndexs.lastSelectRowIndex;

selectIndexs.lastSelectRowIndex =tempIndex;

}

for(var i =selectIndexs.firstSelectRowIndex;i <=selectIndexs.lastSelectRowIndex;i++){

$('#orderDataGrid').datagrid('checkRow',i);

}

selectIndexs.firstSelectRowIndex =0;

selectIndexs.lastSelectRowIndex =0;

}

}

function keyDown(event) {//响应键盘按下事件

    var e = event ||window.event;

var code =e.keyCode |e.which |e.charCode;

switch (code) {

case KEY.SHIFT:

inputFlags.isShiftDown =true;

break;

case KEY.CTRL:

inputFlags.isShiftDown =true;

break;

default:

}

}

orderDataGrid =$('#orderDataGrid').datagrid({

onLoadSuccess:myfilter,

url:'',

striped :true,

rownumbers :true,

pagination :true,

singleSelect:false,

checkOnSelect:true,

selectOnCheck:true,

idField :'id',

sortName :'PayTime',

sortOrder :'desc',

pageSize :100,

onClickRow:function (index, row)

{

MultiSelect(index,row);

},

onCheck:function(index,row){

MultiSelect(index,row);

},

frozenColumns: [[

{field:'id',title:'id',width:'60',checkbox:true },

{field:'tidstr',title:'订单号',width:'150',

sortable :true,

formatter :function(value, row, index) {

return row['id'];

}},]]}

</script>

相关文章

  • easyui使用shift或ctrl多选

    今天在网上找的demo,使用后一直报错,以下为自己修改后的版本。 var KEY = {SHIFT:16,CTRL...

  • IDEA快捷键

    高频率使用的: Ctrl+/ 或 Ctrl+Shift+/ 注释(// 或者/*...*/ ) Ctrl+D 复制...

  • webstorm快捷键

    Ctrl+/或Ctrl+Shift+/ 注释(//或者/*…*/) Shift+F6 ...

  • webstorm快捷键

    Ctrl+/ 或 Ctrl+Shift+/注释(// 或者/…/ ) Shift+F6 重构-重命名 ...

  • webstorm

    Ctrl+/ 或 Ctrl+Shift+/ 注释(// 或者/…/ )Shift+F6 重构-重命名Ct...

  • WebStorm快捷键

    快捷键功能Ctrl + / 或 Ctrl + Shift + /注释(// 或者/…/ )Shift + F6重构...

  • 笔记

    ctrl shift alt e 盖章图层 ctrl shift i 反选 构图使用通道扣图

  • webstorm快捷键大全

    Ctrl+/或Ctrl+Shift+/注释(//或者/*…*/) Shift+F6重构-重命名 Ctrl+X删除行...

  • webstrom快捷键

    Ctrl+/或Ctrl+Shift+/注释(//或者/*…*/) Shift+F6重构-重命名 Ctrl+X删除行...

  • Sublime Text 3 技巧

    按住Shift+按住鼠标右键+上下选择:垂直多选 alt+f3:同类全选 ctrl+shift+v: 自适应缩进粘...

网友评论

      本文标题:easyui使用shift或ctrl多选

      本文链接:https://www.haomeiwen.com/subject/migtcqtx.html