Skip to content

Commit

Permalink
Added support for col reorder in range filters - #429
Browse files Browse the repository at this point in the history
  • Loading branch information
vedmack committed Jan 9, 2018
1 parent 7d8f612 commit 5dc8b18
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
6 changes: 3 additions & 3 deletions ChangeLog.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

## 0.9.3 is in beta (grab latest stable from https://github.com/vedmack/yadcf/releases)

* Misc bug fixed issues :
* Added support for col reorder in range filters - https://github.com/vedmack/yadcf/issues/429
* 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
https://github.com/vedmack/yadcf/issues/425 - Filter fails when using data-*
https://github.com/vedmack/yadcf/issues/426 - Bug in column_inner_data_helper, related to #424

https://github.com/vedmack/yadcf/issues/426 - Bug in column_inner_data_helper, related to


## 0.9.2
Expand Down
39 changes: 27 additions & 12 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.4 (grab latest stable from https://github.com/vedmack/yadcf/releases)
* Version: 0.9.3.beta.5 (grab latest stable from https://github.com/vedmack/yadcf/releases)
*
* Author: Daniel Reznick
* Info: https://github.com/vedmack/yadcf
Expand Down Expand Up @@ -495,7 +495,7 @@
}

function initColReorder2(settingsDt, table_selector_jq_friendly) {
if (settingsDt.oSavedState != undefined && settingsDt.oSavedState.ColReorder !== undefined) {
if (settingsDt.oSavedState && settingsDt.oSavedState.ColReorder !== undefined) {
if (plugins[table_selector_jq_friendly] === undefined) {
plugins[table_selector_jq_friendly] = {};
plugins[table_selector_jq_friendly].ColReorder = arraySwapValueWithIndex(settingsDt.oSavedState.ColReorder);
Expand Down Expand Up @@ -896,8 +896,8 @@

function calcColumnNumberFilter(settingsDt, column_number, table_selector_jq_friendly) {
var column_number_filter;
if ((settingsDt.oSavedState != undefined && settingsDt.oSavedState.ColReorder !== undefined) ||
settingsDt._colReorder != undefined ||
if ((settingsDt.oSavedState && settingsDt.oSavedState.ColReorder !== undefined) ||
settingsDt._colReorder ||
(plugins[table_selector_jq_friendly] !== undefined && plugins[table_selector_jq_friendly].ColReorder !== undefined)) {
initColReorder2(settingsDt, table_selector_jq_friendly);
column_number_filter = plugins[table_selector_jq_friendly].ColReorder[column_number];
Expand Down Expand Up @@ -1556,7 +1556,9 @@
to,
date,
event,
columnObj;
columnObj,
column_number_filter,
settingsDt;

if (pDate.type === 'dp') {
event = pDate.target;
Expand All @@ -1570,10 +1572,14 @@
table_selector_jq_friendly = column_number.substring(0, dashIndex);

column_number = column_number.substring(dashIndex + 1);


oTable = oTables[table_selector_jq_friendly];
settingsDt = getSettingsObjFromTable(oTable);
column_number_filter = calcColumnNumberFilter(settingsDt, column_number, table_selector_jq_friendly);

$.fn.dataTableExt.iApiIndex = oTablesIndex[table_selector_jq_friendly];

oTable = oTables[table_selector_jq_friendly];
columnObj = getOptions(oTable.selector)[column_number];

if (pDate.type === 'dp') {
Expand All @@ -1600,7 +1606,7 @@
if (oTable.fnSettings().oFeatures.bServerSide !== true) {
oTable.fnDraw();
} else {
oTable.fnFilter(from + '-yadcf_delim-' + to, column_number);
oTable.fnFilter(from + '-yadcf_delim-' + to, column_number_filter);
}

if (!oTable.fnSettings().oLoadedState) {
Expand Down Expand Up @@ -1858,9 +1864,14 @@
yadcfState,
column_number = $(event.target).attr('id').replace("yadcf-filter-", "").replace(table_selector_jq_friendly, "").replace("-slider-", ""),
columnObj,
keyUp;
keyUp,
settingsDt,
column_number_filter;

oTable = oTables[table_selector_jq_friendly];
settingsDt = getSettingsObjFromTable(oTable);
column_number_filter = calcColumnNumberFilter(settingsDt, column_number, table_selector_jq_friendly);

columnObj = getOptions(oTable.selector)[column_number];

keyUp = function () {
Expand All @@ -1870,7 +1881,7 @@
if (oTable.fnSettings().oFeatures.bServerSide !== true) {
oTable.fnDraw();
} else {
oTable.fnFilter(ui.values[0] + '-yadcf_delim-' + ui.values[1], column_number);
oTable.fnFilter(ui.values[0] + '-yadcf_delim-' + ui.values[1], column_number_filter);
}
min_val = +$($(event.target).parent().find(".yadcf-filter-range-number-slider-min-tip-hidden")).text();
max_val = +$($(event.target).parent().find(".yadcf-filter-range-number-slider-max-tip-hidden")).text();
Expand Down Expand Up @@ -3203,10 +3214,14 @@
yadcfState,
column_number,
options,
keyUp;
keyUp,
settingsDt,
column_number_filter;

column_number = parseInt($(event.target).attr("id").replace('-from-', '').replace('-to-', '').replace('yadcf-filter-' + table_selector_jq_friendly, ''), 10);
options = getOptions(oTable.selector)[column_number];
settingsDt = getSettingsObjFromTable(oTable);
column_number_filter = calcColumnNumberFilter(settingsDt, column_number, table_selector_jq_friendly);

keyUp = function () {

Expand All @@ -3232,7 +3247,7 @@
if (oTable.fnSettings().oFeatures.bServerSide !== true) {
oTable.fnDraw();
} else {
oTable.fnFilter(min + '-yadcf_delim-' + max, column_number);
oTable.fnFilter(min + '-yadcf_delim-' + max, column_number_filter);
}
if (document.getElementById(fromId).value !== "") {
$("#" + fromId).addClass("inuse");
Expand Down Expand Up @@ -3631,7 +3646,7 @@
if (state === true && settings._oFixedColumns === undefined) {
if ((plugins[table_selector_jq_friendly] !== undefined && plugins[table_selector_jq_friendly].ColReorder !== undefined)) {
col_num = plugins[table_selector_jq_friendly].ColReorder[col_num];
} else if (settings.oSavedState != undefined && settings.oSavedState.ColReorder !== undefined) {
} else if (settings.oSavedState && settings.oSavedState.ColReorder !== undefined) {
col_num = settings.oSavedState.ColReorder[col_num];
}
obj[col_num] = yadcf.getOptions(settings.oInstance.selector)[col_num];
Expand Down

0 comments on commit 5dc8b18

Please sign in to comment.