We've noticed an issue with the GridControl where if you click to disable the filtering via the Checkbox in the lower left corner, then click into a Column's filter dropdown and select an item to filter by, the GridControl will re-enable the filtering, but it will not apply the filter.
Please refer to the attached sample for an example.
To reproduce this issue:
- Once the grid control has loaded, click into the Name column's filter dropdown and filter by any of the items
- Click the checkbox in the lower left corner to disable the filtering on the grid control
- Go back to the Name column, click into the filter dropdown again, and select another item to filter by
- Notice that the checkbox in the lower left is re-enabled, but the grid did not filter by the item you just selected
Debugging the code, after you have filtered by another item in step 3 the control will run through the CustomRowFilter method for each row in the grid, however, at this time the IsFilterEnabled property of the grid is still false, thus all rows are set to a visibility of true. In our case, we need this logic to stay as-is because we have our own extensive custom filtering code that we execute here. The issue here is that we should not even enumerate through this CustomRowFilter method for each row until after the IsFilterEnabled property is set back to true.
Hopefully this would be an easy fix on your end to have your controls set IsFilterEnabled to true before enumerating through your filtering logic, not after.
Thanks in advance!
Dan
PS Apologies for the crude sample, I threw it together quickly using older samples I had from past support tickets
Hi Dan,
As I see, you are using a custom filter only when the IsFilterEnabled property is false:
public virtual void CustomRowFilter(RowFilterEventArgs args) { if (!IsFilterEnabled) { args.Handled = args.Visible = true; } }
GridControl updates the IsFilterEnabled property value after applying a filter. As a result, when you apply a filter after unchecking CheckBox, IsFilterEnabled is false and the args.Visible property is set to true for all visible rows.
Changing GridControl's internal logic may affect different scenarios and other users who have already built their project based on the current behavior. Would you please elaborate on your scenario? I believe, after researching your end goal, we will be able to provide you with an appropriate solution.
Thanks,
Alexander
"As I see, you are using a custom filter only when the IsFilterEnabled property is false"
That is only for this simplified sample app. In our own application we start with this logic and immediately return from the method if filtering is not enabled. We have an elaborate set of filtering logic that we process which we would not want to execute if the Filtering is disabled.
As it stands, this should be classified as a bug. If a new filter is applied and the filtering is re-enabled at the same time, than the logical order of your code should be to set the IsFilteringEnabled property to true, then apply the filter logic -- not the other way around. It doesn't make any sense in the current implementation.
Considering this a bug, I don't think it's fair to say "we don't want to fix a bug because it might break other users' implementations".
Hopefully you'd agree.
Thanks!
Dan
Hi Dan,
Thank you the additional explanation. We agree with your point of view. With the current implementation, there is no proper way to check if a user disabled filter. I.e., if you manually filter grid rows, a user will be unable to quickly turn off the filter.
After additional discussion, we concluded that it makes sense to set IsFilteringEnabled before raising CustomRowFilter. We will let you know once the fix is available.
Great, thank you Ivan!