Skip to content

Commit 5a9621c

Browse files
docs(grid): extract data source request - filter Row example
1 parent 25c9095 commit 5a9621c

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

components/grid/manual-operations.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,20 +230,37 @@ With a few simple loops, you can extract information from the DataSourceRequest
230230
231231
232232
@functions {
233-
MarkupString ConsoleSim { get; set; }// to showcase what you get
233+
MarkupString ConsoleSim { get; set; } // to showcase what you get
234234
235-
//implementation of OnRead
235+
// implementation of OnRead
236236
List<SampleData> CurrPageData { get; set; }
237237
int Total { get; set; }
238238
239239
async Task OnReadHandler(GridReadEventArgs args)
240240
{
241241
string output = string.Empty;
242242
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)
245245
{
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+
}
247264
}
248265
output += "SORTS:<br />";
249266
foreach (SortDescriptor item in args.Request.Sorts)
@@ -252,10 +269,10 @@ With a few simple loops, you can extract information from the DataSourceRequest
252269
}
253270
output += $"Current page: {args.Request.Page}, page size: {args.Request.PageSize}";
254271
255-
//show that data in the UI for a visual aid
272+
// show that data in the UI for a visual aid
256273
ConsoleSim = new MarkupString(output);
257274
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)
259276
var result = PristineData.ToDataSourceResult(args.Request);
260277
CurrPageData = (result.Data as IEnumerable<SampleData>).ToList();
261278
Total = result.Total;

0 commit comments

Comments
 (0)