Skip to content

valueFilter option #68

Closed
Closed

Description

@gmacias711

I am having issues using the valueFilter option to have predefined filters. Currently, in my data I have an attribute called "Colors". I wish to filter color via the valueFilter option for Green.
I have a variable like:

var valueFilter = {"Colors":{"Blue": false, "Red": false, "Orange":false, "Yellow":false, "Purple":false, "Black":false}};

which is stored in the component's state and gets assigned to the pivot table's valueFilter option. This method works for filtering for green by filtering out the other colors. However, if I change the variable to look like:

var valueFilter = {"Colors":{"Green": true}};

It filters out green and displays all of the other colors. How can I use the valueFilter option without assigning each other color to false (I wish to do this because I want to make the color filter dynamic and passed in via props)?

Thanks for your help!

Activity

  1. JonasWangLilly commented on Mar 14, 2019

    @JonasWangLilly

    Did you manage to find the answer to your question? If so do you mind sharing?

  2. gmacias711 commented on Mar 18, 2019

    @gmacias711
    Author

    What I ended up doing was create a function that sets up the value filter and sets all colors to false, omitting the dynamic color.

    filterColors(){
        var Colorarray = ["Blue", "Red", "Orange", "Yellow", "Purple", "Green", "Black"];
    	var valueFilter = {};
    	var filterObj = {};
    	for(var j = 0; j < Colorarray.length; j ++)
    	{
    		if(Colorarray[j] !== this.state.selectedColor)
    		{
    			filterObj[Colorarray[j]] = false;
    		}
    	}
    	valueFilter["Colors"] = filterObj;
    	return(valueFilter);
    }
    
    <PivotTableUI
        valueFilter={this.filterColors()}
    
  3. aboulang commented on Jul 9, 2022

    @aboulang

    I think this may be an implementation issue. From what I can tell the intent was for

    var valueFilter = {"Colors":{"Green": true}};

    to do what gmacias711 expected. Looks like Nicolas merged inclusions and exclusions parameters from pivotable.js (see https://github.com/nicolaskruchten/pivottable/wiki/Parameters about Pivotable.js's inclusions and exclusions parameters ) into one valueFilter but it is not handling the inclusions side correctly. It can be cumbersome to have to collect all the exclusions instead of what should be included -- especially if valueFilter is a prop that currently can not be modified! This is biting me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions