Radzen FilterPanelMenu not working correctly #290

Closed
opened 2026-01-29 17:34:48 +00:00 by claunia · 0 comments
Owner

Originally created by @teengineer on GitHub (Jan 4, 2022).

Describe the bug
Radzen FilterPanelMenu not working correctly, because Something is missing in the function named Filter(string term) in the service (ExampleService) where the menu items are...

To Reproduce

I think the content of the function should be changed as follows

public IEnumerable<Example> Filter(string term)
        {
            if (string.IsNullOrEmpty(term))
                return allExamples;

            bool contains(string value) => value.ToLower().Contains(term.ToLower(), StringComparison.OrdinalIgnoreCase);

            bool filter(Example example) => contains(example.Name) || (example.Tags != null && example.Tags.Any(contains));

            bool deepFilter(Example example) => filter(example) || example.Children?.Any(filter) == true;

            return Examples.Where(category => category.Children?.Any(deepFilter) == true || category.Name.ToLower().Contains(term.ToLower()))
                            .Select(category => new Example
                            {
                                Name = category.Name,
                               //Expanded = true,
                               Expanded = category.Expanded,
                                Children = (category.Children == null) ? null : category.Children.Where(deepFilter).Select(example => new Example
                                {
                                    Name = example.Name,
                                    Path = example.Path,
                                    Icon = example.Icon,
                                   //Expanded = true,
                                   Expanded = example.Expanded,
                                    Children = example.Children
                                }
                                ).ToArray()
                            }).ToList();
        }

Expected behavior
For example, when I search for the word 'Dashboard' in the menu, it does not appear, and when I delete the search criteria, it appears expanded as if there were other items in the Dashboard.

Screenshots
image

Originally created by @teengineer on GitHub (Jan 4, 2022). **Describe the bug** Radzen FilterPanelMenu not working correctly, because Something is missing in the function named Filter(string term) in the service (ExampleService) where the menu items are... **To Reproduce** I think the content of the function should be changed as follows ``` public IEnumerable<Example> Filter(string term) { if (string.IsNullOrEmpty(term)) return allExamples; bool contains(string value) => value.ToLower().Contains(term.ToLower(), StringComparison.OrdinalIgnoreCase); bool filter(Example example) => contains(example.Name) || (example.Tags != null && example.Tags.Any(contains)); bool deepFilter(Example example) => filter(example) || example.Children?.Any(filter) == true; return Examples.Where(category => category.Children?.Any(deepFilter) == true || category.Name.ToLower().Contains(term.ToLower())) .Select(category => new Example { Name = category.Name, //Expanded = true, Expanded = category.Expanded, Children = (category.Children == null) ? null : category.Children.Where(deepFilter).Select(example => new Example { Name = example.Name, Path = example.Path, Icon = example.Icon, //Expanded = true, Expanded = example.Expanded, Children = example.Children } ).ToArray() }).ToList(); } ``` **Expected behavior** For example, when I search for the word 'Dashboard' in the menu, it does not appear, and when I delete the search criteria, it appears expanded as if there were other items in the Dashboard. **Screenshots** ![image](https://user-images.githubusercontent.com/63187528/148028738-6bd465d0-b0d1-4f55-bf50-ceb6309d09cc.png)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#290