Skip to content

Commit

Permalink
Added new datepicker_type: 'bootstrap-datepicker', (use it with momen…
Browse files Browse the repository at this point in the history
…t library) make sure you set separate date format for the plugin and for moment library -

	see example is the github issue, #435

#435
  • Loading branch information
vedmack committed Feb 21, 2018
1 parent 5dc8b18 commit fa56e7d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
## 0.9.3 is in beta (grab latest stable from https://github.com/vedmack/yadcf/releases)

* Added support for col reorder in range filters - https://github.com/vedmack/yadcf/issues/429
* Added new datepicker_type: 'bootstrap-datepicker', (use it with moment library) make sure you set separate date format for the plugin and for moment library -
see example is the github issue, https://github.com/vedmack/yadcf/issues/435
* Misc bug fixed issues:
https://github.com/vedmack/yadcf/issues/422 - column_data_type html doesn't fallback to text
https://github.com/vedmack/yadcf/issues/424 - Parsing html-lists in table-cells for use in filter
Expand Down
30 changes: 24 additions & 6 deletions src/jquery.dataTables.yadcf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Yet Another DataTables Column Filter - (yadcf)
*
* File: jquery.dataTables.yadcf.js
* Version: 0.9.3.beta.5 (grab latest stable from https://github.com/vedmack/yadcf/releases)
* Version: 0.9.3.beta.6 (grab latest stable from https://github.com/vedmack/yadcf/releases)
*
* Author: Daniel Reznick
* Info: https://github.com/vedmack/yadcf
Expand Down Expand Up @@ -243,7 +243,7 @@
Required: false
Type: String
Default value: 'jquery-ui'
Possible values: 'jquery-ui' / 'bootstrap-datetimepicker'
Possible values: 'jquery-ui' / 'bootstrap-datetimepicker' / bootstrap-datepicker
Description: You can choose datapicker library from defined in special notes
Special notes: Currently supported only jQueryUI datepicker (datepicker) and Bootstrap datepicker (eonasdan-bootstrap-datetimepicker)
Bootstrap datepicker depends moment library. This plugin depends moment too.
Expand Down Expand Up @@ -1340,20 +1340,24 @@
return false;
}
try {
if (min.length === (date_format.length + 2) || columnObj.datepicker_type === 'bootstrap-datetimepicker') {
if (min.length === (date_format.length + 2) || columnObj.datepicker_type.indexOf('bootstrap') !== -1) {
if (columnObj.datepicker_type === 'jquery-ui') {
min = (min !== "") ? $.datepicker.parseDate(date_format, min) : min;
} else if (columnObj.datepicker_type === 'bootstrap-datetimepicker') {
min = (min !== "") ? moment(min, columnObj.moment_date_format).toDate() : min;
} else if (columnObj.datepicker_type === 'bootstrap-datepicker') {
min = (min !== "") ? moment(min, columnObj.moment_date_format).toDate() : min;
}
}
} catch (err1) {}
try {
if (max.length === (date_format.length + 2) || columnObj.datepicker_type === 'bootstrap-datetimepicker') {
if (max.length === (date_format.length + 2) || columnObj.datepicker_type.indexOf('bootstrap') !== -1) {
if (columnObj.datepicker_type === 'jquery-ui') {
max = (max !== "") ? $.datepicker.parseDate(date_format, max) : max;
} else if (columnObj.datepicker_type === 'bootstrap-datetimepicker') {
max = (max !== "") ? moment(max, columnObj.moment_date_format).toDate() : max;
} else if (columnObj.datepicker_type === 'bootstrap-datepicker') {
max = (max !== "") ? moment(max, columnObj.moment_date_format).toDate() : max;
}
}
} catch (err2) {}
Expand All @@ -1362,6 +1366,8 @@
val = (val !== "") ? $.datepicker.parseDate(date_format, val) : val;
} else if (columnObj.datepicker_type === 'bootstrap-datetimepicker') {
val = (val !== "") ? moment(val, columnObj.moment_date_format).toDate() : val;
} else if (columnObj.datepicker_type === 'bootstrap-datepicker') {
val = (val !== "") ? moment(val, columnObj.moment_date_format).toDate() : val;
}
} catch (err3) {}

Expand Down Expand Up @@ -1562,6 +1568,8 @@

if (pDate.type === 'dp') {
event = pDate.target;
} else if (pDate.type === 'changeDate') {
event = pDate.currentTarget;
} else {
date = pDate;
event = pEvent;
Expand Down Expand Up @@ -1716,8 +1724,18 @@
$fromInput.add($toInput).on('dp.hide', dateSelect);
}
} else if (columnObj.datepicker_type === 'bootstrap-datepicker') {
//$fromInput.datepicker({});
//$toInput.datepicker({});
$fromInput.datepicker({
format: date_format
}).on('changeDate', function(e) {
dateSelect(e);
$(this).datepicker('hide');
});
$toInput.datepicker({
format: date_format
}).on('changeDate', function(e) {
dateSelect(e);
$(this).datepicker('hide');
});
}

if (oTable.fnSettings().oFeatures.bStateSave === true && oTable.fnSettings().oLoadedState) {
Expand Down

0 comments on commit fa56e7d

Please sign in to comment.