Fix small bugs in table.js

This commit is contained in:
Duncan Sommerville 2015-11-09 13:59:36 -05:00
parent 48f09c44ca
commit 1bc0f9e54b
3 changed files with 17 additions and 12 deletions

View file

@ -114,8 +114,8 @@ var AIRTIME = (function(AIRTIME) {
*/
if (bItemSelection) {
$(self._datatable, 'tbody tr').on('click contextmenu', self._SELECTORS.SELECTION_TABLE_ROW, function (e) {
var aData = self._datatable.fnGetData($(this).index());
var iDisplayIndex = $(this).index(); //The index of the row in the current page in the table.
var aData = self._datatable.fnGetData(this);
var iDisplayIndex = $(this).index(); // The index of the row in the current page in the table.
var nRow = this;
e.stopPropagation();
@ -148,6 +148,11 @@ var AIRTIME = (function(AIRTIME) {
e.stopPropagation();
return true;
});
// Clear selection when switching pages
$(self._datatable).on('page', function () {
self.clearSelection();
});
}
// On filter, display the number of total and filtered results in the search bar
@ -254,7 +259,7 @@ var AIRTIME = (function(AIRTIME) {
return outerDiv;
};
Table.prototype._clearSelection = function() {
Table.prototype.clearSelection = function() {
this._selectedRows = [];
//self._selectedRowVisualIdxMap = [];
this._selectedRowVisualIdxMin = self.HUGE_INT;
@ -283,8 +288,7 @@ var AIRTIME = (function(AIRTIME) {
//Regular single left-click mode
if (selectionMode == self.SELECTION_MODE.SINGLE) {
self._clearSelection();
self.clearSelection();
self._selectedRows.push(aData);
self._selectedRowVisualIdxMin = iVisualRowIdx;