Custom search in List propery

I want to be able to search in propery and in the list of a property. I can't get it to work and haven't found anything in the documentation how to accomplish this


<SfGrid @ref="Grid" DataSource="@Data" AllowPaging="true" AllowSorting="true" Query="@SearchQuery">
    <SfToolbar>
        <ToolbarItems>
            <ToolbarItem Type="ItemType.Input" Align="Syncfusion.Blazor.Navigations.ItemAlign.Right">
                <Template>
                    <span class="e-search-icon e-icons me-2"></span>
                    <SfTextBox Placeholder="Search" Input="OnInput"></SfTextBox>
                </Template>
            </ToolbarItem>
        </ToolbarItems>
    </SfToolbar>
<GridColumns>
<GridColumn Field="Name" HeaderText="Name" Width="120">
            <Template>
                @{
                    var data = context as Parent;
                    <span>@data?.Name</span>
                }

            </Template>
        </GridColumn>

        <GridColumn HeaderText="Childs" Width="120">
            <Template>
                @{
                    var data = context as Parent;
                    @foreach (var child in data?.Childs)
                    {
                        <div>@child.Name</div>
                    }
                }

            </Template>
        </GridColumn>
</GridColumns> <SfGrid>

private SfGrid<Parent> Grid;
public Query SearchQuery { get; set; }
List<WhereFilter> Predicate = new List<WhereFilter>();
WhereFilter ColumnPredicate = new WhereFilter();


    public void OnInput(InputEventArgs args)
    {
        //this.Grid.SearchAsync(args.Value);
        Predicate = new List<WhereFilter>();
        Predicate.Add(new WhereFilter()
            {
                Field = "Name",
                value = args.Value,
                Operator = "contains",
                IgnoreCase = true
            });
            Predicate.Add(new WhereFilter()
            {
                Field = "Childs.ChildName",
                value = args.Value,
                Operator = "contains",
                IgnoreCase = true
            });
           
        ColumnPredicate = WhereFilter.Or(Predicate);
        SearchQuery = new Query().Where(ColumnPredicate);
    }


Data classes

    public class Parent
    {
        public Parent()
        {
            this.Childs = new List<Child>();
        }
        public string Name { get; set; }

        public List<Child> Childs { get; set; }

    }


    public class Child
    {
        public string ChildName { get; set; }

    }




 



1 Reply

SP Sarveswaran Palani Syncfusion Team February 2, 2024 02:57 AM UTC

Hi Jonas,


We have checked your query and we would like to inform that currently we don’t have support for this feature to implement using List<TValue>. Already, we have considered this as a feature task Provide data operation for one to many relationship columns” and added this to our feature request list. Based on specific parameters including product vision and technological feasibility we will implement this feature. This feature will be available in any of our upcoming releases.   


Feedback Link : https://www.syncfusion.com/feedback/12731/provide-data-operation-for-one-to-many-relationship-columns  


You can also communicate with us regarding the open feature at any time using our above feedback report page. We do not have an immediate plan to implement this feature and it will be included in any of our upcoming releases. Please cast your vote to make it count so that we will prioritize the improvement for every release based on demands.


Regards,

Sarvesh


Loader.
Up arrow icon