In code I have declared the CustomFiltered variable as follows:
public List<Imputation> CustomFiltered{ get; set; }
and in the OnInitializedAsync function I query the database and load the results into that list.
The problem I have is when I try to apply a filter to that table after having loaded everything (by code). I have a button that calls a function that does the following:
I don't think that assigning values to the Query property of the grid instance will work. I suggest checking the Filter API demo instead: Blazor DataGrid Filter API
That has a drawback. If I want to filter a "date" column, I can, from the grid filter, insert a "from" and "to" values.
However, if I do it as the link says, the column only has one FilterValue property, so I can't set a double filter on the same column.
Sorry, I had not seen that property. But I still have a doubt, is it possible to convert the string that is stored in grid.Query.Filter to a readable structure to set the values as indicated in that link?
When I save a filter to the database, I access grid.Query.Filter and store a string in this format:
Day > DateTime("2022-09-01") and ((np(EmployeeOwner.Name)) == null ? "" : (np(EmployeeOwner.Name))).ToLower().Contains("test".ToLower ())
I do this because, initially, the columns have empty FilterValue and SecondFilterValue properties. When the user sets a filter, and I access those properties, they are still empty, so I can only get the filter with grid.Query.Filter to store it.
When the user wants to reset a saved filter, according to the documentation, I have to loop through the grid columns and set the FilterValue and SecondFilterValue properties. For that I would need some way to parse the string that I indicated above to be able to establish those columns.
I do not know if there is another way to access the filter established in each column when storing said filter in the database or if there are other properties that store said filter.
That is not what I mean. When I use a custom filter on a column, for example, a dropdown, and I select a value on the web in that dropdown, the variable that is assigned in bind-settings is not set.
Ok, this is exactly what I was looking for. Thank you.
I had started with the Filter API example (mentioned in a comment above), but Blazor doesn't permit modifying component params directly, so I was having to set up an object that my Column referenced, and...it got ugly quickly. This is much better.