@@ -230,20 +230,37 @@ With a few simple loops, you can extract information from the DataSourceRequest
230
230
231
231
232
232
@functions {
233
- MarkupString ConsoleSim { get; set; }// to showcase what you get
233
+ MarkupString ConsoleSim { get; set; } // to showcase what you get
234
234
235
- //implementation of OnRead
235
+ // implementation of OnRead
236
236
List<SampleData> CurrPageData { get; set; }
237
237
int Total { get; set; }
238
238
239
239
async Task OnReadHandler(GridReadEventArgs args)
240
240
{
241
241
string output = string.Empty;
242
242
output += "FILTERS:<br />";
243
- //loop the DataSourceRequest collections to extract the data you require
244
- foreach (FilterDescriptor item in args.Request.Filters)
243
+ // loop the DataSourceRequest collections to extract the data you require
244
+ foreach (var item in args.Request.Filters)
245
245
{
246
- output += $"field: {item.Member}, operator {item.Operator}, value: {item.Value}<br />";
246
+ if(item is FilterDescriptor) // filter row
247
+ {
248
+ FilterDescriptor currFilter = item as FilterDescriptor;
249
+ output += $"field: {currFilter.Member}, operator {currFilter.Operator}, value: {currFilter.Value}<br />";
250
+ }
251
+
252
+ if(item is CompositeFilterDescriptor) // filter menu
253
+ {
254
+ CompositeFilterDescriptor currFilter = item as CompositeFilterDescriptor;
255
+ output += $"START nested filter: logical operator: {currFilter.LogicalOperator}, details:<br />";
256
+ // there will actually be 1 or 2 only, this showcases the concept and the types
257
+ foreach (FilterDescriptor nestedFilter in currFilter.FilterDescriptors)
258
+ {
259
+
260
+ output += $"field: {nestedFilter.Member}, operator {nestedFilter.Operator}, value: {nestedFilter.Value}<br />";
261
+ }
262
+ output += "END nested filter<br />";
263
+ }
247
264
}
248
265
output += "SORTS:<br />";
249
266
foreach (SortDescriptor item in args.Request.Sorts)
@@ -252,10 +269,10 @@ With a few simple loops, you can extract information from the DataSourceRequest
252
269
}
253
270
output += $"Current page: {args.Request.Page}, page size: {args.Request.PageSize}";
254
271
255
- //show that data in the UI for a visual aid
272
+ // show that data in the UI for a visual aid
256
273
ConsoleSim = new MarkupString(output);
257
274
258
- //actual data source operation, implement as required in your case (e.g., call a service with parameters you built)
275
+ // actual data source operation, implement as required in your case (e.g., call a service with parameters you built)
259
276
var result = PristineData.ToDataSourceResult(args.Request);
260
277
CurrPageData = (result.Data as IEnumerable<SampleData>).ToList();
261
278
Total = result.Total;
0 commit comments