Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue 459: StyleClass for column filters #781

Merged
merged 4 commits into from
Jan 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default {
filterOptions: {
enabled: true,
filterDropdownItems: ['24', '16', '30'],
styleClass: 'class1'
// filterDropdownItems: [
// {
// value: 24,
Expand Down
11 changes: 9 additions & 2 deletions src/components/VgtFilterRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
<tr v-if="hasFilterRow">
<th v-if="lineNumbers"></th>
<th v-if="selectable"></th>
<th class="filter-th"
<th
v-for="(column, index) in columns" :key="index"
v-if="!column.hidden">
v-if="!column.hidden"
:class="getClasses(column)"
>

<slot
name="column-filter"
Expand Down Expand Up @@ -128,6 +130,11 @@ export default {
&& typeof column.filterOptions.filterDropdownItems[0] !== 'object';
},

getClasses(column) {
const firstClass = 'filter-th';
return (column.filterOptions && column.filterOptions.styleClass) ? [firstClass, ...column.filterOptions.styleClass.split(' ')].join(' ') : firstClass;
},

// get column's defined placeholder or default one
getPlaceholder(column) {
const placeholder = (this.isFilterable(column) && column.filterOptions.placeholder) || `Filter ${column.label}`;
Expand Down
8 changes: 7 additions & 1 deletion vp-docs/guide/configuration/column-filter-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ columns: [
label: 'name',
field: 'user_name',
filterOptions: {
styleClass: 'class1', // class to be added to the parent th element
enabled: true, // enable filter for this column
placeholder: 'Filter This Thing', // placeholder for filter input
filterValue: 'Jane', // initial populated value for this filter
Expand All @@ -24,6 +25,11 @@ columns: [
]
```

## styleClass

type: `string`
Class to be added to the parent th element. You can specify several classes separated by a space.

## enabled

type: `Boolean`
Expand Down Expand Up @@ -73,4 +79,4 @@ filterFn: function(data, filterString) {
return data >= x - 5 && data <= x + 5;
}
// would create a filter matching numbers within 5 of the provided value
```
```