Ag-Grid Set Filter update list of available values after initialisation - ag-grid

I am using Ag-Grid Enterprise and have applied a set filter to a column, so far so good. I am using Server side row model and am pivoting data successfully on the backend (C# ASP.Net Core).
Once a user applies a filter to one column, I want the other column filters to be updated with a new list of available values that has been limited based upon the column filters that are set.
For example:
Colours:
Black
Orange
Red
Yellow
Blue
In Rainbow:
True
False
Now the idea is that when I set In Rainbow filter to True, I will update the Colours list to exclude black, the logic behind that is done on the C# side and thats fine, basically I fire a query to the server that will include In Rainbow = true, and it will return me an array of the colours that match this particular query.
So I can get the array of colours in javascript back and grab the filter successfully, i.e.
var data = ["Orange", "Red", "Yellow", "Blue"];
var filter = gridOptions.api.getFilterInstance(columnName);
However I cannot find a way to tell ag-grid that I have new values that I want to make available in the set list.
I have tried:
filter.setFilterValues(data);
and
filter.setModel({
type: 'set',
values: data
});
But neither appear to make changes to the set filter values that are available to select.
Any help on this would be greatly appreciated

i'm not sure i completely understand your question but as far as i understand you want to set the values in you filter dynamically or something along these lines and if that's what you want i would suggest that you use filterParams. filterPramas has an attribute for value so it would go like this filterParams:{values:getvalues} get values will bet the function that will return the values you want there is the link to the filterParameters in ag-grid docs https://www.ag-grid.com/javascript-grid-filtering/#filter-parameters

Related

how to persist filter in ag-grid vuejs

How to persist the filter in ag-grid vuejs . I'm trying to apply filter but when I click on a row for looking the data inside the row node the filter selection is removed I meant the grid load from the starting (reset filter). how to persist this filter.
second problem and I'm facing one more problem is that the selection of row is not working in a long time ... I have applied checkbox in the header but when I select the checkbox after a couple of seconds it will automatically deselect ..so my second question is how to apply checkbox the will not deselect automatically. one particular node check box is not working also
thanks in advance I'm new in this technology please help me out from core ...
I guess for the first problem of yours you should set newRowsAction to 'keep' like this.
{field: 'year', filter: 'number', filterParams: {newRowsAction: 'keep'}}
This property is for when using the Client Side Row Model only. When set to 'clear', updating the data in the grid by calling api.setRowData() (or updating the rowData property if bound by a framework) will clear (reset) the filter. If you instead set this to 'keep', the grid will keep its currently set filter when the data is updated.
Default: 'clear'
for the second problem of your its really hard to interpret based on words so it will be good if you can create minimum code working demo(reproducing the error) on plunkr or stackblitz so that we can help you.

Filtering a datasource using multi select wild character

Does anyone know if there is a wildcard character in AppMaker that can be used for all possible values for a field in a query?
I currently have a datasource that is being filtered based on the status using a multi-select widget. What I would like to accomplish is when all values have been de-selected I want to load all the records of that datasource without clearing the entire query in case other filters have been applied. I have it working in-a-sense that I have to explicitly construct my query as such:
widget.datasource.query.filters.Status._in = ['Status Value 1','Status Value 2','Status Value 3']
My current solution is loading the correct data when a value is selected and it correctly shows the union of the query as the values are modified. However, it selects all of the values in my multi-select; which I know is how it is supposed to work.
I tried using widget.datasource.query.filters.Status._contains = ''; and changing the assignment value to no avail. I even tried the opposite approach using _notContains
The intended outcome is to have a filtering dashboard appear much like any website where when no filtering is selected all records are displayed. I was hoping to find a wildcard character that would load all of the records. Just trying to find a way to mimic other website filters with all records when none are selected.
Thanks for the time!
So the easiest solution here is to set up your Multiselect as follows:
Options binding:
#models.YourModel.fields.Status.possibleValues
or if you don't have the possible Status values in your model then set your options binding to:
['Status Value 1','Status Value 2','Status Value 3']
Values binding:
#datasource.query.filters.Status._in
Now anytime you select any choices in the multiselect, the query will only include records that include the selected choices. And if you deselect all choices the query will ignore that filter or treat it as an empty array of values, therefore returning all records unless you applied other filters.

IF ELSE Function through different datas sources

I have two data sources in my Tableau Sheet and i want to create an if else function for true or false.
The two data sources have the same column Name which is Fahrzeug and and there are values in first data source that has the same Fahrzeug Value as the other data source, and i Need a if else function which will give me True if there are the same values in both data sources and False if its not the same.
This is how the Tableau sheet Looks like.
Examples of datasets :
First and the main dataset
Second dataset
Difficult to really know what will work best without knowing what intend to use that Boolean field for. Regardless, I find Tableau fairly poor for iterating through and comparing values in different tables, as that wasn't it's design. Best bet would be process than outside of Tableau, either Tableau Prep or write a script of some kind.
But one possibility using a pure Tableau desktop method would be to just create a new dataset that has a full outer join on the [Fahrzeug] field.
Create a new datasource using a the full outer join on [Fahrzueg] in FFE_Ausfalldaten.csv and FFE_Boxplot.csv
That gives you a null in the left dataset when it appears only in the right, and vice versa. With the same value in both [Fahrzeug] field's when it appears in both.
Then create a calculated field in the new datasource called [Fahrzeug_Bool] or whatever you want
iif((ISNULL([Fahrzeug1])=True or ISNULL([Fahrzeug2])),FALSE,TRUE)
this assigns False is either Fahrzeug field is null (i.e. only common in one file), True otherwise
Then edit the datasource relationships so the [Fahrzeug] fields in the individual fields (FFEAusfalldaten.csv and FFEBoxplots.csv) are linked to the corresponding [Fahrzeug1] and [Fahrzeug2] fields in the joined dataset.
Pull the individual fields into view along with the [Fahrzeug_Bool] field and validate they are True or False as expected

how to create multiple filters from one dimension tableau (10)?

I have a two dimensions with the following data set
Original Dimension
I would like to create two filters that can be used to filter my dashboard. These two filter would be called - "Product_Type" and "Product" and should have the following drop downs:
Filter Breakdown
To summarize, I am looking for a way to take my original dimension and create the filter breakdowns so that in my dashboard I can have two filter (Product_type and Product). When i click on the Product_type filter, i should be able to see "overall", "fruits", "vegetable" and "leafy. Based on my selection , the Product filter should automatically show only the relevant values - i.e. if i picked "leafy" it should only show "spinach" and "kale". Finally if i select "kale" my entire dashboard should change accordingly.
Looking for a way to do this without drastically affecting the performance.
update: i was able to achieve this by creating multiple parameters and then using the pop window technique (https://vimeo.com/107352893) - but this has affected my workbook performance very badly. Need another solution!!
You should be able to accomplish your desired functionality by creating a calculated field for product type and a CASE statement to classify the products based on the product type you specified your image.
Further, filters can be configured to display available values based on the other filters in place. I would recommend having your Product Type filter a the "context" or "data-source" level, and your product filter at the lowest level, so that the selectable options for the product filter can be displayed using the "only relevant Values" option and limits the products that can be chosen.
Please see the following link for some more information on filtering hierarchies
Performance Related
General Filtering
Blog Post
"Only relevant values - Specifies which values to show in the filter. When you select this option other filters are considered and only values that pass these filters are shown. For example, a filter on State will only show the Eastern states when a filter on Region is set. You can use the toggle at the top of the filter card to switch between this option and the All Values in Database option.
All values in database - Specifies which values to show in the filter. When you select this option all values in the database are shown regardless of the other filters on the view.
All values in context (Tableau Desktop only) - When one of the filters in the view is a context filter, select this option on a different filter to only display values that pass through the context filter. For more information, see Improve View Performance with Context Filters."

Tableau parameter filter with multiple values?

In Tableau 9.2, I currently have a parameter set up which contains multiple string values and an additional "All" value. I also have a calculated field which only contains the Str([some_field]) function. I have then dragged this calculated field into the "filters" pane and from there enabled "use all" and put the following formula under the "condition" tab:
// If All is selected, then do not filter
[my_filter_parameter] = 'All' OR
// Otherwise, filter on the current parameter
[my_filter_parameter] = [my_calculated_Field]
After creating the calculated field for multiple sheets in my dashboard (which use different data sources all contain the common some_field), then I can change the parameter's value and it will filter all of the sheets at once.
My issue is that I need this to take on multiple values at once via a check-box. I understand that a parameter can only take on one value at a time, so I am wondering how I can do this without making the same filter for each individual sheet in the dashboard. Perhaps this can be done with a calculated field?
EDIT: I have tried the technique here to make a global filter via a control view. This allows me to use Ctrl+Clicking to select multiple values in some_field at once, however I still do not have a dropdown box. Alternatively, if anyone knows how to use this method with a dropdown box, then that would be another solution.
If I am understanding your situation correctly, I have accomplished this using the following:
Create a calculated field and put the following code:
if [parameters].parametername = 'All' then true
elseif [parameters].parametername = FILTEREDCOLUMN then true
else false
end
Add that calculated field to the filters pane and select "True" - in other words, filter out any records where the calculated field is False. If the parameter you selected is "All" then all records will be True. Otherwise, it will only be True if the parameter matches the FILTEREDCOLUMN. I hope that helps.
Parameter can pass only one value at a time ,i.e. Parameter Control will have Single Drop Down List.