We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Excel filter for complex object column

Hi,

How do I get Excel filter to work on complex object column? e.g. Text Filter "contains" for Cust.Name.First is not showing filtered data correctly 


@page "/"


<SfGrid DataSource="@Orders" AllowPaging="true" AllowSorting="true" AllowFiltering="true" AllowGrouping="true">

    <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Excel" />

 <GridPageSettings PageSize="5"></GridPageSettings>

   <GridColumns>

     <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>

     @*<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>*@

        <GridColumn Field="Cust.Name.First" HeaderText="Customer Name First" Width="150"></GridColumn>

        <GridColumn Field="Cust.Name.Last" HeaderText="Customer Name Last" Width="150"></GridColumn>

        <GridColumn Field="Cust.Country" HeaderText="Customer Country" Width="150"></GridColumn>

     <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>

     <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>

        <GridColumn Field="Term" HeaderText="Term" Width="150"></GridColumn>

   </GridColumns>

</SfGrid>


@code{

    public List<Order> Orders { get; set; }


    protected override void OnInitialized()

    {

        Orders = Enumerable.Range(1, 75).Select(x => new Order()

            {

                OrderID = 1000 + x,

                Cust = new Customer

                {

                    Name = new FullName

                    {

                        First = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],

                        Last = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)]

                    },

                    Country = (new string[] { "ENGLAND", "IRAN", "USA", "WHALES", "QATAR" })[new Random().Next(5)]

                },

                //CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],

                Freight = 2.1 * x,

                OrderDate = DateTime.Now.AddDays(-x),

                Term = (new string[] { "EXW", "FCA", "FOB", "DAT", "CNF" })[new Random().Next(5)]

            }).ToList();

    }


    public class FullName {

        public string First { get; set; }

        public string Last { get; set; }

    }


    public class Customer {

        public FullName Name { get; set; }

        public string Country { get; set; }

    }


    public class Order {

        public int? OrderID { get; set; }

        //public string CustomerID { get; set; }

        public Customer Cust { get; set; }

        public DateTime? OrderDate { get; set; }

        public double? Freight { get; set; }

        public string Term { get; set; }

    }

}


Attachment: DataGridSample_9fe779fe.zip

2 Replies

SP Sarveswaran Palani Syncfusion Team November 24, 2022 11:34 PM

Hi Patrick,

Greetings from Syncfusion support.

From your query, we suspect that you want to excel filter the complex column and based on your sample we’re able to filter the complex column in the provided sample. Kindly refer the attached video demo of your reference. If we misunderstood your query, kindly share the vide demo or more details about an issue. It’ll will be very helpful for us to validate the reported query at our end and provide the solution as early as possible


Regards,

Sarveswaran PK


Attachment: SfGridXcelFilter_68295404.zip


PL patrick lo, November 25, 2022 12:00 AM

Dear  Sarveswaran ,

Please see video. 

Value in text box disappears after losing focus for complex object. Hence, unable to filter.

Regards,

Patrick


Attachment: DataGrid_bd42f81.zip

Loader.
Live Chat Icon For mobile
Up arrow icon