diff --git a/src/utils/columnUtils.js b/src/utils/columnUtils.js index 3786c25c..6d0aadc7 100644 --- a/src/utils/columnUtils.js +++ b/src/utils/columnUtils.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; const offset = 1000; /** Gets a column properties object from an array of columnNames @@ -7,7 +8,7 @@ function getColumnPropertiesFromColumnArray(columnProperties, columns) { return columns.reduce((previous, current, i) => { previous[current] = { id: current, order: offset + i }; return previous; - }, + }, columnProperties); } @@ -23,7 +24,7 @@ export function getColumnProperties(rowProperties, allColumns=[]) { // Working against an array of columnProperties if (Array.isArray(children)) { // build one object that contains all of the column properties keyed by id - children.reduce((previous, current, i) => { + _.reduce(_.flatten(children),(previous, current, i) => { if (current) { previous[current.props.id] = {order: offset + i, ...current.props}; } @@ -39,5 +40,5 @@ export function getColumnProperties(rowProperties, allColumns=[]) { getColumnPropertiesFromColumnArray(columnProperties, allColumns); } - return columnProperties; + return columnProperties; } diff --git a/stories/index.tsx b/stories/index.tsx index fbe503ce..f0b649a1 100644 --- a/stories/index.tsx +++ b/stories/index.tsx @@ -265,6 +265,21 @@ storiesOf('Griddle main', module) ) }) + .add("with filterable set by array of ", () => { + const ids = ["name", "city", "state"]; + return ( +
+ Name is not filterable + + + {ids.map(id => ( + + ))} + + +
+ ); + }) .add('with local and sort set', () => { const sortProperties = [ { id: 'name', sortAscending: true } @@ -1768,4 +1783,4 @@ storiesOf('TypeScript', module) ); - }) + }) \ No newline at end of file