mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-09 18:06:53 +02:00
Re-refactored number type, continued
This commit is contained in:
parent
7ecb53a701
commit
bfe7293619
58
dist/tablefilter/tablefilter.js
vendored
58
dist/tablefilter/tablefilter.js
vendored
|
@ -1949,7 +1949,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
var searchArgs = this.getFiltersValue();
|
||||
|
||||
var numData = void 0;
|
||||
var nbFormat = this.decimalSeparator;
|
||||
var decimal = this.decimalSeparator;
|
||||
var re_le = new RegExp(this.leOperator),
|
||||
re_ge = new RegExp(this.geOperator),
|
||||
re_l = new RegExp(this.lwOperator),
|
||||
|
@ -2024,6 +2024,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
var parseDate = dateType.parse.bind(dateType);
|
||||
var locale = dateType.getOptions(colIdx).locale || this.locale;
|
||||
|
||||
// Search arg dates tests
|
||||
var isLDate = hasLO && isValidDate(sA.replace(re_l, ''), locale);
|
||||
var isLEDate = hasLE && isValidDate(sA.replace(re_le, ''), locale);
|
||||
var isGDate = hasGR && isValidDate(sA.replace(re_g, ''), locale);
|
||||
|
@ -2090,55 +2091,36 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
occurence = (0, _string.contains)(sA, cellData, this.isExactMatch(colIdx), this.caseSensitive);
|
||||
}
|
||||
} else {
|
||||
//first numbers need to be unformatted
|
||||
// if (this.hasType(colIdx, [NUMBER])) {
|
||||
// numData = Number(cellData);
|
||||
// }
|
||||
// else if (this.hasType(colIdx,
|
||||
// [FORMATTED_NUMBER, FORMATTED_NUMBER_EU])) {
|
||||
// numData =unformatNb(cellData, this.colTypes[colIdx]);
|
||||
// nbFormat = this.colTypes[colIdx];
|
||||
// } else {
|
||||
// if (this.thousandsSeparator === ',' &&
|
||||
// this.decimalSeparator === '.') {
|
||||
// nbFormat = FORMATTED_NUMBER;
|
||||
// } else {
|
||||
// nbFormat = FORMATTED_NUMBER_EU;
|
||||
// }
|
||||
// numData = unformatNb(cellData, nbFormat);
|
||||
// }
|
||||
|
||||
if (this.hasType(colIdx, [_const.NUMBER
|
||||
/*, FORMATTED_NUMBER, FORMATTED_NUMBER_EU*/])) {
|
||||
if (this.hasType(colIdx, [_const.FORMATTED_NUMBER])) {
|
||||
var colType = this.colTypes[colIdx];
|
||||
if (colType.hasOwnProperty('decimal')) {
|
||||
nbFormat = colType.decimal;
|
||||
decimal = colType.decimal;
|
||||
}
|
||||
// numData = Number(cellData) ||parseNb(cellData, nbFormat);
|
||||
// numData = Number(cellData) ||parseNb(cellData, decimal);
|
||||
}
|
||||
// else {
|
||||
// numData = Number(cellData) ||
|
||||
// parseNb(cellData, tf.decimalSeparator);
|
||||
// }
|
||||
numData = Number(cellData) || (0, _number.parse)(cellData, nbFormat);
|
||||
numData = Number(cellData) || (0, _number.parse)(cellData, decimal);
|
||||
|
||||
// first checks if there is any operator (<,>,<=,>=,!,*,=,{,},
|
||||
// rgx:)
|
||||
// lower equal
|
||||
if (hasLE) {
|
||||
occurence = numData <= (0, _number.parse)(sA.replace(re_le, ''), nbFormat);
|
||||
occurence = numData <= (0, _number.parse)(sA.replace(re_le, ''), decimal);
|
||||
}
|
||||
//greater equal
|
||||
else if (hasGE) {
|
||||
occurence = numData >= (0, _number.parse)(sA.replace(re_ge, ''), nbFormat);
|
||||
occurence = numData >= (0, _number.parse)(sA.replace(re_ge, ''), decimal);
|
||||
}
|
||||
//lower
|
||||
else if (hasLO) {
|
||||
occurence = numData < (0, _number.parse)(sA.replace(re_l, ''), nbFormat);
|
||||
occurence = numData < (0, _number.parse)(sA.replace(re_l, ''), decimal);
|
||||
}
|
||||
//greater
|
||||
else if (hasGR) {
|
||||
occurence = numData > (0, _number.parse)(sA.replace(re_g, ''), nbFormat);
|
||||
occurence = numData > (0, _number.parse)(sA.replace(re_g, ''), decimal);
|
||||
}
|
||||
//different
|
||||
else if (hasDF) {
|
||||
|
@ -2183,11 +2165,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
} else {
|
||||
// If numeric type data, perform a strict equality test and
|
||||
// fallback to unformatted number string comparison
|
||||
if (numData && this.hasType(colIdx, [_const.NUMBER]) && !this.singleSearchFlt) {
|
||||
if (numData && this.hasType(colIdx, [_const.NUMBER, _const.FORMATTED_NUMBER]) && !this.singleSearchFlt) {
|
||||
// parseNb can return 0 for strings which are not
|
||||
// formatted numbers, in that case return the original
|
||||
// string. TODO: handle this in parseNb
|
||||
sA = (0, _number.parse)(sA, nbFormat) || sA;
|
||||
sA = (0, _number.parse)(sA, decimal) || sA;
|
||||
occurence = numData === sA || (0, _string.contains)(sA.toString(), numData.toString(), this.isExactMatch(colIdx), this.caseSensitive);
|
||||
} else {
|
||||
// Finally test search term is contained in cell data
|
||||
|
@ -2346,17 +2328,17 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
continue;
|
||||
}
|
||||
var cellData = this.getCellData(cell[j]);
|
||||
// let nbFormat = this.hasType(colIndex,
|
||||
// let decimal = this.hasType(colIndex,
|
||||
// [FORMATTED_NUMBER, FORMATTED_NUMBER_EU]) ?
|
||||
// this.colTypes[colIndex] : undefined;
|
||||
var decimal = this.decimalSeparator;
|
||||
if (this.hasType(colIndex, [_const.NUMBER])) {
|
||||
if (this.hasType(colIndex, [_const.FORMATTED_NUMBER])) {
|
||||
var colType = this.colTypes[colIndex];
|
||||
if (colType.hasOwnProperty('decimal')) {
|
||||
decimal = colType.decimal;
|
||||
}
|
||||
}
|
||||
var data = num ? (0, _number.parse)(cellData, decimal) : cellData;
|
||||
var data = num ? Number(cellData) || (0, _number.parse)(cellData, decimal) : cellData;
|
||||
colValues.push(data);
|
||||
}
|
||||
}
|
||||
|
@ -4688,12 +4670,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
*/
|
||||
var FORMATTED_NUMBER = exports.FORMATTED_NUMBER = 'formatted-number';
|
||||
|
||||
/**
|
||||
* Formatted number
|
||||
* @type {String}
|
||||
*/
|
||||
var FORMATTED_NUMBER_EU = exports.FORMATTED_NUMBER_EU = 'formatted-number-eu';
|
||||
|
||||
/**
|
||||
* Date
|
||||
* @type {String}
|
||||
|
@ -10220,8 +10196,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
// Global locale
|
||||
this.datetime.setLocale(this.locale);
|
||||
|
||||
// let locale = this.datetime.getLocale(this.locale);
|
||||
|
||||
// Add formats from column types configuration if any
|
||||
this.addConfigFormats(this.tf.colTypes);
|
||||
// locale.addFormat('{dd}/{MM}/{yyyy}');
|
||||
|
@ -10256,7 +10230,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
var _this = this;
|
||||
|
||||
var types = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
|
||||
console.log(types);
|
||||
|
||||
types.forEach(function (type, idx) {
|
||||
var options = _this.getOptions(idx, types);
|
||||
if (options.hasOwnProperty('format')) {
|
||||
|
|
40
dist/tablefilter/tf-1.js
vendored
40
dist/tablefilter/tf-1.js
vendored
|
@ -2841,12 +2841,13 @@ webpackJsonp([1],{
|
|||
if ((0, _types.isObj)(colType)) {
|
||||
if (colType.type === _const.DATE) {
|
||||
colType = this._addDateType(i, sortTypes);
|
||||
} else if (colType.type === _const.NUMBER) {
|
||||
} else if (colType.type === _const.FORMATTED_NUMBER) {
|
||||
var decimal = colType.decimal || tf.decimalSeparator;
|
||||
colType = this._addNumberType(i, decimal);
|
||||
}
|
||||
} else {
|
||||
colType = colType.toLowerCase();
|
||||
// TODO: normalise 'none' vs 'None'
|
||||
if (colType === _const.NONE) {
|
||||
colType = 'None';
|
||||
}
|
||||
|
@ -2854,30 +2855,6 @@ webpackJsonp([1],{
|
|||
} else {
|
||||
colType = _const.STRING;
|
||||
}
|
||||
// if (sortTypes[i]) {
|
||||
// colType = sortTypes[i];
|
||||
// if (isObj(colType)) {
|
||||
// if (colType.type === DATE) {
|
||||
// colType = this._addDateType(i, sortTypes);
|
||||
// }
|
||||
// else if (colType.type === NUMBER) {
|
||||
|
||||
// }
|
||||
// }
|
||||
// colType = colType.toLowerCase();
|
||||
// if (colType === NONE) {
|
||||
// colType = 'None';
|
||||
// }
|
||||
// } else { // resolve column types
|
||||
// if (tf.hasType(i, [NUMBER/*, FORMATTED_NUMBER,
|
||||
// FORMATTED_NUMBER_EU, IP_ADDRESS*/])) {
|
||||
// colType = tf.colTypes[i].toLowerCase();
|
||||
// } else if (tf.hasType(i, [DATE])) {
|
||||
// colType = this._addDateType(i);
|
||||
// } else {
|
||||
// colType = STRING;
|
||||
// }
|
||||
// }
|
||||
_sortTypes.push(colType);
|
||||
}
|
||||
|
||||
|
@ -2887,10 +2864,8 @@ webpackJsonp([1],{
|
|||
this.addSortType(_const.NUMBER, Number);
|
||||
this.addSortType('caseinsensitivestring', SortableTable.toUpperCase);
|
||||
this.addSortType(_const.STRING);
|
||||
// this.addSortType(FORMATTED_NUMBER, usNumberConverter);
|
||||
// this.addSortType(FORMATTED_NUMBER_EU, euNumberConverter);
|
||||
this.addSortType(_const.IP_ADDRESS, ipAddress, sortIP);
|
||||
console.log(_sortTypes);
|
||||
|
||||
this.stt = new SortableTable(tf.tbl, _sortTypes);
|
||||
|
||||
/*** external table headers adapter ***/
|
||||
|
@ -2932,7 +2907,7 @@ webpackJsonp([1],{
|
|||
};
|
||||
|
||||
AdapterSortableTable.prototype._addNumberType = function _addNumberType(colIndex, decimal) {
|
||||
var colType = _const.NUMBER + '-format' + (decimal === '.' ? '' : '-custom');
|
||||
var colType = '' + _const.FORMATTED_NUMBER + (decimal === '.' ? '' : '-custom');
|
||||
|
||||
this.addSortType(colType, function (value) {
|
||||
return (0, _number.parse)(value, decimal);
|
||||
|
@ -2975,12 +2950,7 @@ webpackJsonp([1],{
|
|||
}(_feature.Feature);
|
||||
|
||||
//Converters
|
||||
// function usNumberConverter(s) {
|
||||
// return parseNb(s, FORMATTED_NUMBER);
|
||||
// }
|
||||
// function euNumberConverter(s) {
|
||||
// return parseNb(s, FORMATTED_NUMBER_EU);
|
||||
// }
|
||||
|
||||
|
||||
exports.default = AdapterSortableTable;
|
||||
function ipAddress(value) {
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
"string-replace-webpack-plugin": "^0.0.3",
|
||||
"sugar-date": "2.0.0",
|
||||
"webpack": "^1.13.2",
|
||||
"webpack-dev-server": "^1.15.1"
|
||||
"webpack-dev-server": "^1.16.1"
|
||||
},
|
||||
"dependencies": {},
|
||||
"bugs": {
|
||||
|
|
|
@ -95,12 +95,6 @@ export const NUMBER = 'number';
|
|||
*/
|
||||
export const FORMATTED_NUMBER = 'formatted-number';
|
||||
|
||||
/**
|
||||
* Formatted number
|
||||
* @type {String}
|
||||
*/
|
||||
export const FORMATTED_NUMBER_EU = 'formatted-number-eu';
|
||||
|
||||
/**
|
||||
* Date
|
||||
* @type {String}
|
||||
|
|
|
@ -4,8 +4,8 @@ import {createElm, elm, getText, tag} from '../../dom';
|
|||
import {addEvt} from '../../event';
|
||||
import {parse as parseNb} from '../../number';
|
||||
import {
|
||||
NONE, CELL_TAG, HEADER_TAG, STRING, NUMBER, DATE, /*FORMATTED_NUMBER,
|
||||
FORMATTED_NUMBER_EU,*/ IP_ADDRESS
|
||||
NONE, CELL_TAG, HEADER_TAG, STRING, NUMBER, DATE, FORMATTED_NUMBER,
|
||||
IP_ADDRESS
|
||||
} from '../../const';
|
||||
|
||||
/**
|
||||
|
@ -407,12 +407,13 @@ export default class AdapterSortableTable extends Feature {
|
|||
if (colType.type === DATE) {
|
||||
colType = this._addDateType(i, sortTypes);
|
||||
}
|
||||
else if (colType.type === NUMBER) {
|
||||
else if (colType.type === FORMATTED_NUMBER) {
|
||||
let decimal = colType.decimal || tf.decimalSeparator;
|
||||
colType = this._addNumberType(i, decimal);
|
||||
}
|
||||
} else {
|
||||
colType = colType.toLowerCase();
|
||||
// TODO: normalise 'none' vs 'None'
|
||||
if (colType === NONE) {
|
||||
colType = 'None';
|
||||
}
|
||||
|
@ -420,30 +421,6 @@ export default class AdapterSortableTable extends Feature {
|
|||
} else {
|
||||
colType = STRING;
|
||||
}
|
||||
// if (sortTypes[i]) {
|
||||
// colType = sortTypes[i];
|
||||
// if (isObj(colType)) {
|
||||
// if (colType.type === DATE) {
|
||||
// colType = this._addDateType(i, sortTypes);
|
||||
// }
|
||||
// else if (colType.type === NUMBER) {
|
||||
|
||||
// }
|
||||
// }
|
||||
// colType = colType.toLowerCase();
|
||||
// if (colType === NONE) {
|
||||
// colType = 'None';
|
||||
// }
|
||||
// } else { // resolve column types
|
||||
// if (tf.hasType(i, [NUMBER/*, FORMATTED_NUMBER,
|
||||
// FORMATTED_NUMBER_EU, IP_ADDRESS*/])) {
|
||||
// colType = tf.colTypes[i].toLowerCase();
|
||||
// } else if (tf.hasType(i, [DATE])) {
|
||||
// colType = this._addDateType(i);
|
||||
// } else {
|
||||
// colType = STRING;
|
||||
// }
|
||||
// }
|
||||
_sortTypes.push(colType);
|
||||
}
|
||||
|
||||
|
@ -453,10 +430,8 @@ export default class AdapterSortableTable extends Feature {
|
|||
this.addSortType(NUMBER, Number);
|
||||
this.addSortType('caseinsensitivestring', SortableTable.toUpperCase);
|
||||
this.addSortType(STRING);
|
||||
// this.addSortType(FORMATTED_NUMBER, usNumberConverter);
|
||||
// this.addSortType(FORMATTED_NUMBER_EU, euNumberConverter);
|
||||
this.addSortType(IP_ADDRESS, ipAddress, sortIP);
|
||||
console.log(_sortTypes);
|
||||
|
||||
this.stt = new SortableTable(tf.tbl, _sortTypes);
|
||||
|
||||
/*** external table headers adapter ***/
|
||||
|
@ -496,7 +471,7 @@ export default class AdapterSortableTable extends Feature {
|
|||
}
|
||||
|
||||
_addNumberType(colIndex, decimal) {
|
||||
let colType = `${NUMBER}-format${decimal === '.' ? '' : '-custom'}`;
|
||||
let colType = `${FORMATTED_NUMBER}${decimal === '.' ? '' : '-custom'}`;
|
||||
|
||||
this.addSortType(colType, (value) => {
|
||||
return parseNb(value, decimal);
|
||||
|
@ -533,13 +508,6 @@ export default class AdapterSortableTable extends Feature {
|
|||
}
|
||||
|
||||
//Converters
|
||||
// function usNumberConverter(s) {
|
||||
// return parseNb(s, FORMATTED_NUMBER);
|
||||
// }
|
||||
// function euNumberConverter(s) {
|
||||
// return parseNb(s, FORMATTED_NUMBER_EU);
|
||||
// }
|
||||
|
||||
function ipAddress(value) {
|
||||
let vals = value.split('.');
|
||||
for (let x in vals) {
|
||||
|
|
|
@ -19,8 +19,6 @@ export class DateType {
|
|||
// Global locale
|
||||
this.datetime.setLocale(this.locale);
|
||||
|
||||
// let locale = this.datetime.getLocale(this.locale);
|
||||
|
||||
// Add formats from column types configuration if any
|
||||
this.addConfigFormats(this.tf.colTypes);
|
||||
// locale.addFormat('{dd}/{MM}/{yyyy}');
|
||||
|
@ -51,7 +49,7 @@ export class DateType {
|
|||
return isObj(colType) ? colType : {};
|
||||
}
|
||||
|
||||
addConfigFormats(types=[]) {console.log(types);
|
||||
addConfigFormats(types=[]) {
|
||||
types.forEach((type, idx) => {
|
||||
let options = this.getOptions(idx, types);
|
||||
if (options.hasOwnProperty('format')) {
|
||||
|
|
|
@ -31,8 +31,7 @@ import {DateType} from './modules/dateType';
|
|||
import {
|
||||
INPUT, SELECT, MULTIPLE, CHECKLIST, NONE,
|
||||
ENTER_KEY, TAB_KEY, ESC_KEY, UP_ARROW_KEY, DOWN_ARROW_KEY,
|
||||
CELL_TAG, AUTO_FILTER_DELAY, NUMBER, DATE/*, FORMATTED_NUMBER,
|
||||
FORMATTED_NUMBER_EU*/
|
||||
CELL_TAG, AUTO_FILTER_DELAY, NUMBER, DATE, FORMATTED_NUMBER
|
||||
} from './const';
|
||||
|
||||
let doc = root.document;
|
||||
|
@ -1753,7 +1752,7 @@ export class TableFilter {
|
|||
let searchArgs = this.getFiltersValue();
|
||||
|
||||
let numData;
|
||||
let nbFormat = this.decimalSeparator;
|
||||
let decimal = this.decimalSeparator;
|
||||
let re_le = new RegExp(this.leOperator),
|
||||
re_ge = new RegExp(this.geOperator),
|
||||
re_l = new RegExp(this.lwOperator),
|
||||
|
@ -1826,6 +1825,7 @@ export class TableFilter {
|
|||
let parseDate = dateType.parse.bind(dateType);
|
||||
let locale = dateType.getOptions(colIdx).locale || this.locale;
|
||||
|
||||
// Search arg dates tests
|
||||
let isLDate = hasLO &&
|
||||
isValidDate(sA.replace(re_l, ''), locale);
|
||||
let isLEDate = hasLE &&
|
||||
|
@ -1902,36 +1902,18 @@ export class TableFilter {
|
|||
}
|
||||
|
||||
else {
|
||||
//first numbers need to be unformatted
|
||||
// if (this.hasType(colIdx, [NUMBER])) {
|
||||
// numData = Number(cellData);
|
||||
// }
|
||||
// else if (this.hasType(colIdx,
|
||||
// [FORMATTED_NUMBER, FORMATTED_NUMBER_EU])) {
|
||||
// numData =unformatNb(cellData, this.colTypes[colIdx]);
|
||||
// nbFormat = this.colTypes[colIdx];
|
||||
// } else {
|
||||
// if (this.thousandsSeparator === ',' &&
|
||||
// this.decimalSeparator === '.') {
|
||||
// nbFormat = FORMATTED_NUMBER;
|
||||
// } else {
|
||||
// nbFormat = FORMATTED_NUMBER_EU;
|
||||
// }
|
||||
// numData = unformatNb(cellData, nbFormat);
|
||||
// }
|
||||
|
||||
if (this.hasType(colIdx, [NUMBER])) {
|
||||
if (this.hasType(colIdx, [FORMATTED_NUMBER])) {
|
||||
let colType = this.colTypes[colIdx];
|
||||
if (colType.hasOwnProperty('decimal')) {
|
||||
nbFormat = colType.decimal;
|
||||
decimal = colType.decimal;
|
||||
}
|
||||
// numData = Number(cellData) ||parseNb(cellData, nbFormat);
|
||||
// numData = Number(cellData) ||parseNb(cellData, decimal);
|
||||
}
|
||||
// else {
|
||||
// numData = Number(cellData) ||
|
||||
// parseNb(cellData, tf.decimalSeparator);
|
||||
// }
|
||||
numData = Number(cellData) || parseNb(cellData, nbFormat);
|
||||
numData = Number(cellData) || parseNb(cellData, decimal);
|
||||
|
||||
// first checks if there is any operator (<,>,<=,>=,!,*,=,{,},
|
||||
// rgx:)
|
||||
|
@ -1939,28 +1921,28 @@ export class TableFilter {
|
|||
if (hasLE) {
|
||||
occurence = numData <= parseNb(
|
||||
sA.replace(re_le, ''),
|
||||
nbFormat
|
||||
decimal
|
||||
);
|
||||
}
|
||||
//greater equal
|
||||
else if (hasGE) {
|
||||
occurence = numData >= parseNb(
|
||||
sA.replace(re_ge, ''),
|
||||
nbFormat
|
||||
decimal
|
||||
);
|
||||
}
|
||||
//lower
|
||||
else if (hasLO) {
|
||||
occurence = numData < parseNb(
|
||||
sA.replace(re_l, ''),
|
||||
nbFormat
|
||||
decimal
|
||||
);
|
||||
}
|
||||
//greater
|
||||
else if (hasGR) {
|
||||
occurence = numData > parseNb(
|
||||
sA.replace(re_g, ''),
|
||||
nbFormat
|
||||
decimal
|
||||
);
|
||||
}
|
||||
//different
|
||||
|
@ -2015,14 +1997,12 @@ export class TableFilter {
|
|||
// If numeric type data, perform a strict equality test and
|
||||
// fallback to unformatted number string comparison
|
||||
if (numData &&
|
||||
this.hasType(colIdx,
|
||||
[NUMBER
|
||||
/*, FORMATTED_NUMBER, FORMATTED_NUMBER_EU*/]) &&
|
||||
this.hasType(colIdx, [NUMBER, FORMATTED_NUMBER]) &&
|
||||
!this.singleSearchFlt) {
|
||||
// parseNb can return 0 for strings which are not
|
||||
// formatted numbers, in that case return the original
|
||||
// string. TODO: handle this in parseNb
|
||||
sA = parseNb(sA, nbFormat) || sA;
|
||||
sA = parseNb(sA, decimal) || sA;
|
||||
occurence = numData === sA ||
|
||||
contains(sA.toString(), numData.toString(),
|
||||
this.isExactMatch(colIdx), this.caseSensitive);
|
||||
|
@ -2179,17 +2159,19 @@ export class TableFilter {
|
|||
continue;
|
||||
}
|
||||
let cellData = this.getCellData(cell[j]);
|
||||
// let nbFormat = this.hasType(colIndex,
|
||||
// let decimal = this.hasType(colIndex,
|
||||
// [FORMATTED_NUMBER, FORMATTED_NUMBER_EU]) ?
|
||||
// this.colTypes[colIndex] : undefined;
|
||||
let decimal = this.decimalSeparator;
|
||||
if (this.hasType(colIndex, [NUMBER])) {
|
||||
if (this.hasType(colIndex, [FORMATTED_NUMBER])) {
|
||||
let colType = this.colTypes[colIndex];
|
||||
if (colType.hasOwnProperty('decimal')) {
|
||||
decimal = colType.decimal;
|
||||
}
|
||||
}
|
||||
let data = num ? parseNb(cellData, decimal) : cellData;
|
||||
let data = num ?
|
||||
Number(cellData) || parseNb(cellData, decimal) :
|
||||
cellData;
|
||||
colValues.push(data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,9 +52,7 @@ var tfConfig = {
|
|||
name: 'sort',
|
||||
types: [
|
||||
'number', 'string', 'string',
|
||||
{ type: 'number', decimal: '.' },
|
||||
// 'number',
|
||||
'none', 'string'
|
||||
'formatted-number', 'none', 'string'
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -77,26 +77,24 @@ var tfConfig = {
|
|||
col_types: [
|
||||
'string', 'string', 'string',
|
||||
{
|
||||
type: 'number', decimal: ',', thousands: '.'
|
||||
type: 'formatted-number', decimal: ',', thousands: '.'
|
||||
},
|
||||
'formatted-number', 'string',
|
||||
{
|
||||
type: 'number', decimal: '.', thousands: ','
|
||||
},
|
||||
'string',
|
||||
{
|
||||
type: 'date', locale: 'en',
|
||||
format: ['{dd}/{MM}/{yyyy}', '{dd}-{MM}-{yyyy|yy}']
|
||||
type: 'date', locale: 'fr'/*,
|
||||
format: ['{dd}/{MM}/{yyyy}', '{dd}-{MM}-{yyyy|yy}']*/
|
||||
},
|
||||
{ type: 'date', locale: 'en', format: '{dd}-{MM}-{yyyy|yy}' },
|
||||
{ type: 'date', locale: 'en', format: '{dd}-{months}-{yyyy|yy}' },
|
||||
{ type: 'date', locale: 'en', format: ['{dd}-{months}-{yyyy|yy}'] },
|
||||
'ipaddress'
|
||||
],
|
||||
rows_always_visible: [totRowIndex],
|
||||
on_filters_loaded: function(o){
|
||||
o.setFilterValue(3, '>1.000');
|
||||
o.setFilterValue(4, '<2,500');
|
||||
o.setFilterValue(6, '>23-01-95');
|
||||
o.filter();
|
||||
on_filters_loaded: function(tf){
|
||||
tf.setFilterValue(3, '>1.000');
|
||||
tf.setFilterValue(4, '<2,500');
|
||||
tf.setFilterValue(6, '>23-01-95');
|
||||
tf.setFilterValue(8, '<2000');
|
||||
tf.filter();
|
||||
},
|
||||
extensions:[
|
||||
{ name: 'sort' },
|
||||
|
@ -138,9 +136,9 @@ var tf2Config = {
|
|||
'string', 'number', 'string',
|
||||
'number', 'string', 'date'
|
||||
],
|
||||
on_filters_loaded: function(o){
|
||||
o.setFilterValue(5, '>95-05-18');
|
||||
o.filter();
|
||||
on_filters_loaded: function(tf){
|
||||
tf.setFilterValue(5, '>95-05-18');
|
||||
tf.filter();
|
||||
}
|
||||
};
|
||||
var tf2 = new TableFilter('demo', tf2Config);
|
||||
|
|
Loading…
Reference in a new issue