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

Allow valueFilter to filter-in and filter-out without listing all values. Like an include and exclude. #77

Merged
merged 1 commit into from
Apr 1, 2024

Conversation

raisercostin
Copy link
Contributor

Allow configuration of valueFilter without listing all values for a key. All false will exclude all. Then add the needed one with true. All could also be selected, and exclude the unwanted ones with false. Is also compatible with existing clients.

     Sample:
      ```
      valueFilter: {
        category: {
          all: false,
          'field1': true,
          'field2': false
        }
      }

@Seungwoo321
Copy link
Owner

Seungwoo321 commented Jan 12, 2024

I tested it in the example project and it doesn't work.
I think this is because the default value is falsely when the item is selected. The item you want to exclude must have the value true.

But try changing false to true in the following code:

         if (valueFilterItem && Object.keys(valueFilterItem).length) {
           // add all keys to be filtered out
           if (valueFilterItem.all) { // <-------------------------- here --------------------------
             Object.keys(values).forEach(k => {
               if (k !== 'all') {
                 const keyPresent = valueFilterItem[k]
.
.
.

And I confirmed that if all is true, all values are excluded by default.

       valueFilter: {
         date: {
           all: true
         }
       },

If I misunderstand, please provide sample code.
Please understand that there is no test code.

Thank you for your interest in this project

@raisercostin
Copy link
Contributor Author

Yes. You're right. I changed the meaning. valueFilter meaning is to filter out. I will change to be compatible with existing behavior.

@raisercostin
Copy link
Contributor Author

Fixed. I also changed the 'all' field to '*'. Could be configurable but I didn't want to add complexity.

…nd filter them out (true) or show (false).

Now works in both vue-pivottable-ui and vue-pivottable.

Sample:
```
valueFilter: {
  field1: {
    '*': true, // filter out all values
    'value1': true, // filter out value1
    'value2': false // select to display value2
  },
  field2: {
    '*': false, // select to display all values
    'value1': true, // filter out value1
    'value2': false // select to display value2
  }
}
```
@Seungwoo321 Seungwoo321 merged commit b719f86 into Seungwoo321:master Apr 1, 2024
Seungwoo321 added a commit that referenced this pull request Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants