-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.jqgrid.exts.js
executable file
·73 lines (65 loc) · 2.03 KB
/
jquery.jqgrid.exts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* JqGrid extension 0.1 - jQuery Grid
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to benjamin@gnbit.com so we can send you a copy immediately.
*
* @author Benjamin Gonzales benjain@gnbit.com
* @copyright Copyright (c) 2011 GnBit.SAC. (http://www.gnbit.com)
* @license http://gnbit.com/license/new-bsd New BSD License
* @version 0.1.0
*/
;
(function($) {
$.fn.multiselect = function(rowid, status){
var gridId = this.attr('id');
if($.isArray(rowid) && rowid.length>0){
for(i=0;i<rowid.length;i++){
_set(gridId,rowid[i], status)
}
}else{
_set(gridId,rowid, status)
}
}
function _set(gridId,rowid, status){
if(status){
localStorage[gridId+'.RowId.'+rowid] = rowid;
}else{
localStorage.removeItem(gridId+'.RowId.'+rowid);
}
}
$.fn.multiselectDisplay = function(){
if(localStorage.length>0){
var ids = $(this).getDataIDs();
for (i=0; i<localStorage.length; i++)
{
key = localStorage.key(i);
val = localStorage.getItem(key);
if($.inArray(val,ids) > -1){
$(this).jqGrid('setSelection',val);
}
}
}
}
$.fn.multiselectReset = function(){
localStorage.clear();
}
$.fn.getRowsMultiselect = function (){
var idRows = new Array();
if(localStorage.length>0){
for (i=0; i<localStorage.length; i++){
key = localStorage.key(i);
val = localStorage.getItem(key);
if(val != null){
idRows.push(val);
}
}
}
return idRows;
}
})(jQuery);