Index: lams_central/web/qb/collection.jsp
===================================================================
diff -u -r43d88e533dd5666feeaeab4368982ad8028bfae3 -r4d33113a6642a8c4e598c9606c7bc1f65f07ed71
--- lams_central/web/qb/collection.jsp (.../collection.jsp) (revision 43d88e533dd5666feeaeab4368982ad8028bfae3)
+++ lams_central/web/qb/collection.jsp (.../collection.jsp) (revision 4d33113a6642a8c4e598c9606c7bc1f65f07ed71)
@@ -26,7 +26,6 @@
collectionGrid.jqGrid({
guiStyle: "bootstrap",
iconSet: 'fontAwesome',
- autoencode:false,
caption: collectionGrid.data('collectionName'),
datatype: "xml",
url: "qb/collection/getCollectionGridData.do?collectionUid=" + collectionGrid.data('collectionUid'),
@@ -35,9 +34,10 @@
shrinkToFit: true,
cellEdit: false,
cmTemplate: { title: false, search: false },
- viewrecords: true,
sortorder: "asc",
sortname: "name",
+ multiselect : true,
+ multiPageSelection : true,
pager: true,
rowList:[10,20,30,40,50,100],
rowNum: 10,
@@ -47,15 +47,108 @@
"Stats"
],
colModel:[
- {name:'id', index:'id', sortable:true, width: 10},
- {name:'name',index:'name', sortable:true, search:true, autoencode:true},
- {name:'stats', index:'stats', sortable:false, width: 10, align: "center", formatter: statsLinkFormatter}
+ {name:'id', index:'uid', sortable:true, width: 10},
+ {name:'name', index:'name', sortable:true, search:true, autoencode:true},
+ {name:'stats', index:'stats', classes: "stats-cell", sortable:false, width: 10, align: "center", formatter: statsLinkFormatter}
],
+ onSelectRow : function(id, status, event) {
+ var grid = $(this),
+ included = grid.data('included'),
+ excluded = grid.data('excluded'),
+ selectAllChecked = grid.closest('.ui-jqgrid-view').find('.jqgh_cbox .cbox').prop('checked');
+ if (selectAllChecked) {
+ var index = excluded.indexOf(+id);
+ // if row is deselected, add it to excluded array
+ if (index < 0) {
+ if (!status) {
+ excluded.push(+id);
+ }
+ } else if (status) {
+ excluded.splice(index, 1);
+ }
+ } else {
+ var index = included.indexOf(+id);
+ // if row is selected, add it to included array
+ if (index < 0) {
+ if (status) {
+ included.push(+id);
+ }
+ } else if (!status) {
+ included.splice(index, 1);
+ }
+ }
+ },
+ gridComplete : function(){
+ var grid = $(this),
+ included = grid.data('included'),
+ // cell containing "(de)select all" button
+ selectAllCell = grid.closest('.ui-jqgrid-view').find('.jqgh_cbox > div');
+ // remove the default button provided by jqGrid
+ $('.cbox', selectAllCell).remove();
+ // create own button which follows own rules
+ var selectAllCheckbox = $('')
+ .prop('checked', included === null)
+ .prependTo(selectAllCell)
+ .change(function(){
+ // start with deselecting every question on current page
+ grid.resetSelection();
+ if ($(this).prop('checked')){
+ // on select all change mode and select all on current page
+ grid.data('included', null);
+ grid.data('excluded', []);
+ $('[role="row"]', grid).each(function(){
+ grid.jqGrid('setSelection', +$(this).attr('id'), false);
+ });
+ } else {
+ // on deselect all just change mode
+ grid.data('excluded', null);
+ grid.data('included', []);
+ }
+ });
+ grid.resetSelection();
+ if (selectAllCheckbox.prop('checked')) {
+ var excluded = grid.data('excluded');
+ // go through each loaded row
+ $('[role="row"]', grid).each(function(){
+ var id = +$(this).attr('id'),
+ selected = $(this).hasClass('success');
+ // if row is not selected and is not excluded, select it
+ if (!selected && (!excluded || !excluded.includes(id))) {
+ // select without triggering onSelectRow
+ grid.jqGrid('setSelection', id, false);
+ }
+ });
+ } else {
+ // go through each loaded row
+ $('[role="row"]', grid).each(function(){
+ var id = +$(this).attr('id'),
+ selected = $(this).hasClass('success');
+ // if row is not selected and is included, select it
+ if (!selected && included.includes(id)) {
+ // select without triggering onSelectRow
+ grid.jqGrid('setSelection', id, false);
+ }
+ });
+ }
+ },
+ loadComplete : function(){
+ var grid = $(this),
+ gridView = grid.closest('.ui-jqgrid-view');
+ $('tr.ui-search-toolbar .cbox', gridView).remove();
+
+ $('.stats-cell', gridView).click(function(event){
+ event.stopImmediatePropagation();
+ });
+ },
loadError: function(xhr,st,err) {
collectionGrid.clearGridData();
alert("Error!");
}
}).jqGrid('filterToolbar');
+
+
+ collectionGrid.data('excluded', null)
+ .data('included', []);
});
});