Skip to content

Commit

Permalink
New: dt-api display() method which can be used to programmatically …
Browse files Browse the repository at this point in the history
…control the displayed calender month

DD-2622
https://datatables.net/forums/discussion/76153
  • Loading branch information
AllanJard committed May 2, 2023
1 parent 2a65be1 commit 33d7175
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 5 deletions.
22 changes: 22 additions & 0 deletions dist/dataTables.dateTime.js
Expand Up @@ -216,6 +216,28 @@ $.extend( DateTime.prototype, {
.off('.datetime');
},

display: function (year, month) {
if (year !== undefined) {
this.s.display.setUTCFullYear(year);
}

if (month !== undefined) {
this.s.display.setUTCMonth(month - 1);
}

if (year !== undefined || month !== undefined) {
this._setTitle();
this._setCalander();

return this;
}

return {
month: this.s.display.getUTCMonth() + 1,
year: this.s.display.getUTCFullYear()
};
},

errorMsg: function ( msg ) {
var error = this.dom.error;

Expand Down
2 changes: 1 addition & 1 deletion dist/dataTables.dateTime.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dataTables.dateTime.min.mjs

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions dist/dataTables.dateTime.mjs
Expand Up @@ -180,6 +180,28 @@ $.extend( DateTime.prototype, {
.off('.datetime');
},

display: function (year, month) {
if (year !== undefined) {
this.s.display.setUTCFullYear(year);
}

if (month !== undefined) {
this.s.display.setUTCMonth(month - 1);
}

if (year !== undefined || month !== undefined) {
this._setTitle();
this._setCalander();

return this;
}

return {
month: this.s.display.getUTCMonth() + 1,
year: this.s.display.getUTCFullYear()
};
},

errorMsg: function ( msg ) {
var error = this.dom.error;

Expand Down
28 changes: 25 additions & 3 deletions js/dataTables.dateTime.js
@@ -1,12 +1,12 @@
/*! DateTime picker for DataTables.net v1.4.1
/*! DateTime picker for DataTables.net v1.5.0-dev
*
* © SpryMedia Ltd, all rights reserved.
* License: MIT datatables.net/license/mit
*/

/**
* @summary DateTime picker for DataTables.net
* @version 1.4.1
* @version 1.5.0-dev
* @file dataTables.dateTime.js
* @author SpryMedia Ltd
* @contact www.datatables.net/contact
Expand Down Expand Up @@ -174,6 +174,28 @@ $.extend( DateTime.prototype, {
.off('.datetime');
},

display: function (year, month) {
if (year !== undefined) {
this.s.display.setUTCFullYear(year);
}

if (month !== undefined) {
this.s.display.setUTCMonth(month - 1);
}

if (year !== undefined || month !== undefined) {
this._setTitle();
this._setCalander();

return this;
}

return {
month: this.s.display.getUTCMonth() + 1,
year: this.s.display.getUTCFullYear()
};
},

errorMsg: function ( msg ) {
var error = this.dom.error;

Expand Down Expand Up @@ -1613,7 +1635,7 @@ DateTime.defaults = {
yearRange: 25
};

DateTime.version = '1.4.1';
DateTime.version = '1.5.0-dev';

/**
* CommonJS factory function pass through. Matches DataTables.
Expand Down

0 comments on commit 33d7175

Please sign in to comment.