From 3258121a157f33c3a4768c681cf41bc07a2cf9de Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 7 Jan 2020 14:36:45 -0700 Subject: [PATCH] Api: Fix some nextmatch bugs - default columns were not properly used if there was no user preference found - negated column preference caused problems with column order - missing data for sorting if no column preference set yet --- api/js/etemplate/et2_extension_nextmatch.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/api/js/etemplate/et2_extension_nextmatch.js b/api/js/etemplate/et2_extension_nextmatch.js index f8f4d3ec76..e2f4ed2a33 100644 --- a/api/js/etemplate/et2_extension_nextmatch.js +++ b/api/js/etemplate/et2_extension_nextmatch.js @@ -806,7 +806,7 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_ negated = this.options.settings.default_cols[0] == "!"; columnPreference = negated ? this.options.settings.default_cols.substring(1) : this.options.settings.default_cols; } - if(this.options.settings.selectcols) + if(this.options.settings.selectcols && this.options.settings.selectcols.length) { columnPreference = this.options.settings.selectcols; negated = false; @@ -953,7 +953,10 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_ _colData[i].width = parseInt(size[colName])+'px'; } } - _colData[i].order = typeof order[colName] === 'undefined' ? i : order[colName]; + if(!negated) + { + _colData[i].order = typeof order[colName] === 'undefined' ? i : order[colName]; + } for(var j = 0; j < columnDisplay.length; j++) { if(columnDisplay[j] == colName) @@ -971,7 +974,14 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_ return a.order - b.order; }); _row.sort(function(a,b) { - return a.colData.order - b.colData.order; + if(typeof a.colData !== 'undefined' && typeof b.colData !== 'undefined') + { + return a.colData.order - b.colData.order; + } + else if (typeof a.order !== 'undefined' && typeof b.order !== 'undefined') + { + return a.order - b.order; + } }); },