Skip to content

Commit d218ca0

Browse files
feat: add string array support to solo object properties
1 parent 5e67d66 commit d218ca0

File tree

8 files changed

+2772
-1910
lines changed

8 files changed

+2772
-1910
lines changed

README.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,64 @@ React.render(
143143
)
144144
```
145145

146+
## Solo Filtering ##
147+
148+
The `solo` prop allows you to filter data to show only specific values. It supports both single values and arrays for multi-value filtering.
149+
150+
### Single Value Filtering (Original Behavior)
151+
152+
```jsx
153+
<ReactPivot
154+
solo={{ firstName: 'John', state: 'NY' }}
155+
// ... other props
156+
/>
157+
```
158+
159+
### Array Value Filtering (New Feature)
160+
161+
```jsx
162+
<ReactPivot
163+
solo={{
164+
firstName: ['John', 'Jane', 'Bob'],
165+
state: ['NY', 'CA']
166+
}}
167+
// ... other props
168+
/>
169+
```
170+
171+
### Mixed Value Filtering
172+
173+
```jsx
174+
<ReactPivot
175+
solo={{
176+
firstName: ['John', 'Jane'], // Multiple values
177+
department: 'Engineering', // Single value
178+
state: ['NY', 'CA', 'TX'] // Multiple values
179+
}}
180+
// ... other props
181+
/>
182+
```
183+
184+
### Filtering Logic
185+
186+
- **Within arrays**: Uses OR logic (matches any value in the array)
187+
- **Between properties**: Uses AND logic (all properties must match)
188+
- **Empty arrays**: Filter out all rows for that property
189+
- **Display**: Array values are shown as comma-separated strings
190+
191+
### Example
192+
193+
```jsx
194+
// This configuration:
195+
solo={{
196+
state: ['NY', 'CA'],
197+
department: ['Sales', 'Marketing']
198+
}}
199+
200+
// Would match rows where:
201+
// (state === 'NY' OR state === 'CA') AND (department === 'Sales' OR department === 'Marketing')
202+
```
203+
146204
See it all together in [example/basic.jsx](https://github.com/davidguttman/react-pivot/blob/master/example/basic.jsx)
147205

148206
### Optional Arguments ###
@@ -154,7 +212,7 @@ csvTemplateFormat | boolean | apply template formatting to data before csv expor
154212
defaultStyles | boolean | apply default styles from style.css | true
155213
hiddenColumns | array | columns that should not display | []
156214
nPaginateRows | number | items per page setting | 25
157-
solo | object | item that should be displayed solo | null
215+
solo | object | item that should be displayed solo. Values can be strings or arrays of strings for multi-value filtering | null
158216
sortBy | string | name of column to use for record sort | null
159217
sortDir | string | sort direction, either 'asc' or 'desc' | 'asc'
160218
tableClassName | string | assign css class to table containing react-pivot elements | ''

0 commit comments

Comments
 (0)