From ad468130ca08ffa2ec2c98c3509d259f375834c2 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 1 Oct 2013 12:23:09 -0400 Subject: [PATCH] FEATURE Added Datepicker Year/Month option + getAllRows Added feature to have default value in options so the user can select whether the datepicker in jTable forms let's the user directly change the month and the year. Added feature to allow user to call public jTable.getAllRows(), analogous to jTable.getSelectedRows(). Instead of just returning the selected rows, we now return all the rows in the jTable (and thus underlying data). Modified both the jquery.jtable.js source with these changes, as well as the underlying dev source with identical changes. --- dev/jquery.jtable.core.js | 2 ++ dev/jquery.jtable.forms.js | 4 +++- dev/jquery.jtable.selecting.js | 13 +++++++++++++ lib/jquery.jtable.js | 19 ++++++++++++++++++- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/dev/jquery.jtable.core.js b/dev/jquery.jtable.core.js index 62a3d95c..ba2361dc 100644 --- a/dev/jquery.jtable.core.js +++ b/dev/jquery.jtable.core.js @@ -24,6 +24,8 @@ fields: {}, animationsEnabled: true, defaultDateFormat: 'yy-mm-dd', + defaultDateChangeYear: false, /* Default: Let the year be modified in this jTable's create/edit calendar popup */ + defaultDateChangeMonth: false, /* Default: Let the month be modified in this jTable's create/edit calendar popup */ dialogShowEffect: 'fade', dialogHideEffect: 'fade', showCloseButton: false, diff --git a/dev/jquery.jtable.forms.js b/dev/jquery.jtable.forms.js index b497a7e5..2ada2828 100644 --- a/dev/jquery.jtable.forms.js +++ b/dev/jquery.jtable.forms.js @@ -107,7 +107,9 @@ } var displayFormat = field.displayFormat || this.options.defaultDateFormat; - $input.datepicker({ dateFormat: displayFormat }); + /* changeYear and changeMonth are jQuery UI datepicker modal options ... make Year/Month optionally editable */ + /* datepicker year and month are editable depending on options.defaultDateChangeYear, options.defaultDateChangeMonth */ + $input.datepicker({ dateFormat: displayFormat, changeYear: this.options.defaultDateChangeYear, changeMonth: this.options.defaultDateChangeMonth }); return $('
') .addClass('jtable-input jtable-date-input') .append($input); diff --git a/dev/jquery.jtable.selecting.js b/dev/jquery.jtable.selecting.js index 1c6dd60c..33a43984 100644 --- a/dev/jquery.jtable.selecting.js +++ b/dev/jquery.jtable.selecting.js @@ -87,6 +87,12 @@ return this._getSelectedRows(); }, + /* Gets jQuery selection for all rows. + *************************************************************************/ + allRows: function() { + return this._getAllRows(); + }, + /* Makes row/rows 'selected'. *************************************************************************/ selectRows: function ($rows) { @@ -238,6 +244,13 @@ .find('>tr.jtable-row-selected'); }, + /* Gets all rows (selected or not). + *************************************************************************/ + _getAllRows: function () { + return this._$tableBody + .find('>tr.jtable-data-row'); + }, + /* Adds selectable feature to a row. *************************************************************************/ _makeRowSelectable: function ($row) { diff --git a/lib/jquery.jtable.js b/lib/jquery.jtable.js index 243b9b17..39f803aa 100644 --- a/lib/jquery.jtable.js +++ b/lib/jquery.jtable.js @@ -53,6 +53,8 @@ THE SOFTWARE. fields: {}, animationsEnabled: true, defaultDateFormat: 'yy-mm-dd', + defaultDateChangeYear: false, /* Default: Let the year be modified in this jTable's create/edit calendar popup */ + defaultDateChangeMonth: false, /* Default: Let the month be modified in this jTable's create/edit calendar popup */ dialogShowEffect: 'fade', dialogHideEffect: 'fade', showCloseButton: false, @@ -1523,7 +1525,9 @@ THE SOFTWARE. } var displayFormat = field.displayFormat || this.options.defaultDateFormat; - $input.datepicker({ dateFormat: displayFormat }); + /* changeYear and changeMonth are jQuery UI datepicker modal options ... make Year/Month optionally editable */ + /* datepicker year and month are editable depending on options.defaultDateChangeYear, options.defaultDateChangeMonth */ + $input.datepicker({ dateFormat: displayFormat, changeYear: this.options.defaultDateChangeYear, changeMonth: this.options.defaultDateChangeMonth }); return $('
') .addClass('jtable-input jtable-date-input') .append($input); @@ -3091,6 +3095,12 @@ THE SOFTWARE. return this._getSelectedRows(); }, + /* Gets jQuery selection for all rows. + *************************************************************************/ + allRows: function() { + return this._getAllRows(); + }, + /* Makes row/rows 'selected'. *************************************************************************/ selectRows: function ($rows) { @@ -3242,6 +3252,13 @@ THE SOFTWARE. .find('>tr.jtable-row-selected'); }, + /* Gets all rows (selected or not). + *************************************************************************/ + _getAllRows: function () { + return this._$tableBody + .find('>tr.jtable-data-row'); + }, + /* Adds selectable feature to a row. *************************************************************************/ _makeRowSelectable: function ($row) {