I have a grid that lists some records that have a column called Status. The initial state of the grid does not include any records with a status of "Finished" but I want to allow the user to remove that filter as they need to.
When I use the code below it does not allow me to set a default filter in the grid which can be removed by the end user.
private async Task OnStateInitHandler(GridStateEventArgs<FlagVM> args)
{
var cfd = new CompositeFilterDescriptor()
{
FilterDescriptors = new FilterDescriptorCollection()
{
new FilterDescriptor() { Member = "Status/Name", Operator = FilterOperator.DoesNotContain, Value = "Finished", MemberType = typeof(string) }
},
LogicalOperator = FilterCompositionLogicalOperator.And
};
var state = new GridState<FlagVM>
{
FilterDescriptors = new List<IFilterDescriptor>() {}
};
state.FilterDescriptors.Add(cfd);
args.GridState = state;
}
I've also tried something like this with no luck. I basically want to set the UI filter to an initial state for the user.
protected async Task SetGridDefaultFilter()
{
GridState<FlagVM> desiredState = new()
{
FilterDescriptors = new List<IFilterDescriptor>()
{
new CompositeFilterDescriptor(){
FilterDescriptors = new FilterDescriptorCollection()
{
new FilterDescriptor() { Member = "Status/Name", Operator = FilterOperator.DoesNotContain, Value = "Approved", MemberType = typeof(string) }
},
LogicalOperator= FilterCompositionLogicalOperator.And
}
}
};
await GridRef.SetState(desiredState);