easyui使用shift或ctrl多選

今天在網(wǎng)上找的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) {//響應(yīng)鍵盤按下事件

? ? 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>

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 找到fullcalendar.js, 找到代碼為 isRTL:false,這句話 輸入以下幾句 monthName...
    迷你小小白閱讀 1,863評論 0 1
  • "use strict";function _classCallCheck(e,t){if(!(e instanc...
    久些閱讀 2,142評論 0 2
  • pyspark.sql模塊 模塊上下文 Spark SQL和DataFrames的重要類: pyspark.sql...
    mpro閱讀 9,920評論 0 13
  • 今天又發(fā)現(xiàn)一家好吃的餅,嘿嘿嘿。新來的小伙伴忒厲害了,鴨梨大大滴~也還是不太清楚人的聚集地啊,哪里比較適合我呀一類...
    小貝灬閱讀 136評論 0 0
  • 每天叫醒我的不是夢想,是早餐!??! 健康粗糧加小鍋米線,勝過人間無數(shù)。 小云姐簡直是仙女下凡,啥都會做,做得又美又...
    宇過天晴Yuki閱讀 253評論 0 2

友情鏈接更多精彩內(nèi)容