From 551ec91e23ded6e7821884fb6fdb90969ac4ab73 Mon Sep 17 00:00:00 2001 From: emher Date: Sat, 28 Nov 2020 17:20:59 +0100 Subject: [PATCH] Added support for passing function handles as columns formatters. --- dash_tabulator/package-info.json | 1 + package-lock.json | 2 +- package.json | 1 + src/lib/components/DashTabulator.react.js | 9 +++++++-- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dash_tabulator/package-info.json b/dash_tabulator/package-info.json index 95b2d1c..af53277 100644 --- a/dash_tabulator/package-info.json +++ b/dash_tabulator/package-info.json @@ -24,6 +24,7 @@ "author": "patrick oleary ", "license": "MIT", "dependencies": { + "dash-extensions": "0.0.1", "ramda": "^0.26.1", "react-tabulator": "^0.14.2", "set-blocking": "^2.0.0" diff --git a/package-lock.json b/package-lock.json index 3a073d7..d136ec0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "dash_tabulator", - "version": "0.0.5", + "version": "0.1.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 95b2d1c..af53277 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "author": "patrick oleary ", "license": "MIT", "dependencies": { + "dash-extensions": "0.0.1", "ramda": "^0.26.1", "react-tabulator": "^0.14.2", "set-blocking": "^2.0.0" diff --git a/src/lib/components/DashTabulator.react.js b/src/lib/components/DashTabulator.react.js index 5dd09c2..813ad03 100644 --- a/src/lib/components/DashTabulator.react.js +++ b/src/lib/components/DashTabulator.react.js @@ -4,6 +4,7 @@ import PropTypes, { array } from 'prop-types'; import 'react-tabulator/lib/styles.css'; // required styles import 'react-tabulator/lib/css/tabulator.min.css'; // theme import { ReactTabulator } from 'react-tabulator' +import {resolveProps} from 'dash-extensions' /** * DashTabulator is an implementation of the React Tabulator from @@ -37,9 +38,13 @@ export default class DashTabulator extends Component { } render() { - const {id, data, setProps, columns, options, rowClicked, cellEdited, dataChanged, + const {id, data, setProps, columns, options, rowClicked, cellEdited, dataChanged, downloadButtonType, clearFilterButtonType, initialHeaderFilter, dataFiltering, dataFiltered} = this.props; - + // Interpret column formatters as function handles. + for(let i=0; i < columns.length; i++){ + columns[i] = resolveProps(columns[i], ["formatter"]) + } + const options2 = {...options, downloadDataFormatter: (data) => data, downloadReady: (fileContents, blob) => blob