agregar funcion de aplicar formato se se encuentra en la definicion de la columna

This commit is contained in:
dehernandezm 2025-01-24 11:24:09 -06:00
parent be6785152b
commit 43e3abb8c7
3 changed files with 60 additions and 8 deletions

View File

@ -212,13 +212,65 @@ function makeRenderer() {
};
} : null;
var getFinalFormat = function getFinalFormat(objCol) {
if (objCol.type !== 'number' || objCol.format != null && objCol.format.includes('Q')) {
return objCol.format;
}
if (objCol.format.includes('.')) {
if (objCol.number_decimals != null) {
var numberDecimals = parseInt(objCol.number_decimals);
var resultDecimals = '';
if (numberDecimals && !isNaN(numberDecimals) && numberDecimals > 0) {
var counter = 0;
resultDecimals = '.';
while (counter < numberDecimals) {
resultDecimals = resultDecimals + '0';
counter += 1;
}
}
return objCol.format.replace('.00', resultDecimals);
}
return objCol.format;
}
return objCol.format;
};
var getLocaleConfig = function getLocaleConfig(objCol) {
if (objCol.type !== 'number' || objCol.format != null && objCol.format.includes('Q')) {
return null;
}
return {
delimiters: {
thousands: objCol.delimiter_thousands != null ? objCol.delimiter_thousands : ',',
decimal: objCol.delimiter_decimal != null ? objCol.delimiter_decimal : '.'
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
currency: {
symbol: objCol.currency_symbol != null ? objCol.currency_symbol : '$'
}
};
};
var getFormatedValue = function getFormatedValue(aggregator, rowKey, colKey) {
console.log('aggregator', aggregator);
console.log('rowKey', rowKey);
console.log('colKey', colKey);
console.log('props.headersDefinitions', _this2.props.headersDefinitions);
console.log('props', _this2.props);
return '';
var valToFormat = aggregator.value();
var resultValue = aggregator.format(valToFormat);
var keyColumnaCalculo = _this2.props.vals != null && _this2.props.vals.length ? _this2.props.vals[0] : null;
if (keyColumnaCalculo != null && _this2.props.headersDefinitions != null && _this2.props.headersDefinitions.length) {
var _definition = _this2.props.headersDefinitions[keyColumnaCalculo];
if (_definition != null && _definition.value != null) {
if (_definition.value.startsWith('count_') || _definition.value.startsWith('countd_')) {
resultValue = _this2.props.functions != null ? _this2.props.functions.formatedValue(valToFormat, '0,0', 'number', true, '') : resultValue;
} else if (_definition.format != null && _definition.format !== '') {
resultValue = _this2.props.chartFunctions != null ? _this2.props.chartFunctions.formatedValue(valToFormat, getFinalFormat(_definition), _definition.type, true, '', getLocaleConfig(_definition)) : resultValue;
}
}
}
return resultValue;
};
return _react2.default.createElement(

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "v-react-pivottable",
"version": "0.11.23",
"version": "0.11.24",
"description": "A React-based pivot table",
"main": "PivotTableUI.js",
"files": [