如何在反应表中按类别过滤?

时间:2020-05-12 07:55:43

标签: arrays categories react-table

对于每个表列,我都有react-table的类别ID数组,如何为此应用过滤器?

示例:

此一维数组易于过滤。

// 'status' data structure
let status = ['external', 'published', 'other status']

// column object
...
      {
        Header: 'Status',
        accessor: 'status',
        Filter: SimpleFilter,
      },
...

如何过滤此二维数组?

let postsCategoryIds = [[1, 2], [1], [2, 3], [], [3]]

// If I choose 1, the result should be like this:
let result = [[1, 2], [1]]

// If I choose 2, the result should be like this:
let result = [[1, 2], [2, 3]]
// column object
...
      {
        Header: 'Categories',
        accessor: 'category',
        Filter: NotSoSimpleFilterGoesHere,
      },
...

0 个答案:

没有答案