I have just for the first time tried server side paging and filtering using the ToDataSourceResultAsync extension.
This works REALLY well.
The only problem I have, is that I can't filter and sort on computed values in my view model as I can when all data manipulation is on the wasm client.
Can I somehow mix server and client sorting? I would like to filter the current page on a field's not in the database. So not another roundtrip only the data on the client.
UPDATE
I am adding filters on the client. It works but the resulting sql uses AND, should be OR
On the client:
private async Task OnReadHandler(GridReadEventArgs arg)
{
Query.GridRequest = arg.Request;
var request = Query.GridRequest;
var searchBoxFilter = request.Filters.SelectMemberDescriptors().Where(x => x.Member == "ProductName").ToList();
if(searchBoxFilter.Any())
{
var clientFilter = new FilterDescriptor{Member = "ClientName", Operator = FilterOperator.Contains, Value = searchBoxFilter.First().Value.ToString()};
request.Filters.Add(clientFilter);
var initialsFilter = new FilterDescriptor{Member = "UserInitials", Operator = FilterOperator.Contains, Value = searchBoxFilter.First().Value.ToString()};
request.Filters.Add(initialsFilter);
}
var envelope = await TradeOverviewService.GetCertificateTradeRequestsForTradeOverView(Query);
arg.Data = envelope.CurrentPageData.ToList();
arg.Total = envelope.TotalItemCount;
}
Part of the sql
FROM "IBEX"."V_CERTIFICATE_TRADE_REQUEST" "v"
WHERE (("v"."FLOW_TYPE" NOT IN (8, 10)) AND ((((LOWER("v"."PRODUCT_NAME_INTERNAL") LIKE '%sydbank%') AND (LOWER("v"."CLIENT_NAME") LIKE '%sydbank%')) AND (LOWER("v"."USER_INITIALS") LIKE '%sydbank%'))))
ORDER BY "v"."TRADE_DATE" DESC
OFFSET :p_0 ROWS FETCH NEXT :p_1 ROWS ONLY
So can I create the filters so the resulting sql will be.
FROM "IBEX"."V_CERTIFICATE_TRADE_REQUEST" "v"
WHERE (("v"."FLOW_TYPE" NOT IN (8, 10)) AND ((((LOWER("v"."PRODUCT_NAME_INTERNAL") LIKE '%sydbank%') OR (LOWER("v"."CLIENT_NAME") LIKE '%sydbank%')) OR (LOWER("v"."USER_INITIALS") LIKE '%sydbank%'))))
ORDER BY "v"."TRADE_DATE" DESC
OFFSET :p_0 ROWS FETCH NEXT :p_1 ROWS ONLY