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

8 Replies

SP Sarveswaran Palani Syncfusion Team November 25, 2022 04:34 AM UTC

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 05:00 AM UTC

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


NP Naveen Palanivel Syncfusion Team December 12, 2022 04:57 PM UTC

Hi Patrick,  


We are currently Validating  the reported query at our end and we will update the further details shortly. Until then we appreciate your patience.


Regards,

Naveen Palanivel



SP Sarveswaran Palani Syncfusion Team December 16, 2022 03:26 AM UTC

Hi Patrick,


Greetings from Syncfusion support.

We have confirmed this as an issue and logged the defect report “ Input character is not maintained when using complex data in AutoComplete ” for the same. Thank you for taking time to report this issue and helping us to improve our product. At Syncfusion, we are committed to fix all validated defects (subject to technological feasibility and Product Development Life Cycle) and this fix will be included in any of our upcoming patch release.

You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.       


https://www.syncfusion.com/feedback/39819/input-character-is-not-maintained-when-using-complex-data-in-autocomplete


Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization”


Regards,

Sarvesh




PL patrick lo, replied to Sarveswaran Palani December 16, 2022 03:31 AM UTC



PG Peter Groft December 16, 2022 08:19 AM UTC

On the Data tab, in the Sort & Filter group, click Advanced. To filter the listed range by copying rows that match your criteria to another area of the worksheet, click Copy to another location, click in the Copy to box, and then click the upper-left corner of the area where you want to paste the rows.


Regards,
Peter



SP Sarveswaran Palani Syncfusion Team December 23, 2022 04:00 AM UTC

Hi Patrick,


Access for the feedback has been given. So, you can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.

Feedback link: https://www.syncfusion.com/feedback/39819/input-character-is-not-maintained-when-using-complex-data-in-autocomplete


We will get back to you once the release gets rolled out successfully along with a fix for the reported issue. 

Regards,

Sarvesh




SP Sarveswaran Palani Syncfusion Team January 20, 2023 04:35 AM UTC

Hi Patrick,

We apologize for any inconvenience caused. We attempted to provide a source-level fix but were unable to do so for the complex column.

We recommend resolving the issue by rendering the AutoComplete component in the Filter Template feature of the Grid. You can refer to the code snippet and sample solution for your reference.


@page "/"

 

@using Syncfusion.Blazor.Grids

@using Syncfusion.Blazor.DropDowns

 

 

<SfGrid DataSource="@Employees" Height="400" AllowSorting=true AllowMultiSorting="true" AllowExcelExport="true" AllowFiltering=true>

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

    <GridColumns>

        <GridColumn Field=@nameof(EmployeeData.EmployeeID) HeaderText="EmployeeID" TextAlign="TextAlign.Right" Width="120"></GridColumn>

        <GridColumn Field="Name.FirstName" HeaderText="First Name" Width="150">

            <FilterTemplate>

                <SfAutoComplete Placeholder="Select a Value" Autofill="true" @bind-Value="@((context as PredicateModel<string>).Value)" TItem="EmployeeData" TValue="string" DataSource="@(Employees)">

 

                    <AutoCompleteFieldSettings Value="Name.FirstName"></AutoCompleteFieldSettings>

                    <AutoCompleteEvents TValue="string" TItem="EmployeeData" CustomValueSpecifier="@FirstName"></AutoCompleteEvents>

                </SfAutoComplete>

            </FilterTemplate>

        </GridColumn>

        <GridColumn Field="Name.LastName" HeaderText="Last Name" Width="130">

            <FilterTemplate>

                <SfAutoComplete Placeholder="Select a Value" Autofill="true" @bind-Value="@((context as PredicateModel<string>).Value)" TItem="EmployeeData" TValue="string" DataSource="@(Employees)">

 

                    <AutoCompleteFieldSettings Value="Name.LastName"></AutoCompleteFieldSettings>

                    <AutoCompleteEvents TValue="string" TItem="EmployeeData" CustomValueSpecifier="@LastName"></AutoCompleteEvents>

                </SfAutoComplete>

            </FilterTemplate>

        </GridColumn>

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

    </GridColumns>

</SfGrid>

 

@code {

    public void FirstName(CustomValueSpecifierEventArgs<EmployeeData> args)

    {

        args.Item = new EmployeeData() { Name = new EmployeeName() { FirstName = args.Text } };

    }

    public void LastName(CustomValueSpecifierEventArgs<EmployeeData> args)

    {

        args.Item = new EmployeeData() { Name = new EmployeeName() { LastName = args.Text } };

    }

 

    public List<EmployeeData> Employees { get; set; }

 

    protected override void OnInitialized()

    {

        Employees = Enumerable.Range(1, 9).Select(x => new EmployeeData()

            {

                EmployeeID = x,

                Name = new EmployeeName()

                {

                    FirstName = (new string[] { "Nancy", "Andrew", "Janet", "Margaret", "Steven" })[new Random().Next(5)],

                    LastName = (new string[] { "Davolio", "Fuller", "Leverling", "Peacock", "Buchanan" })[new Random().Next(5)]

                },

                Title = (new string[] { "Sales Representative", "Vice President, Sales", "Sales Manager",

                                              "Inside Sales Coordinator" })[new Random().Next(4)],

            }).ToList();

    }

 

    public class EmployeeData

    {

        public int? EmployeeID { get; set; }

        public EmployeeName Name { get; set; }

        public string Title { get; set; }

    }

 

    public class EmployeeName

    {

        public string FirstName { get; set; }

        public string LastName { get; set; }

    }

}


Please let us know if you have any further questions or concerns.

Regards,
Sarvesh


Attachment: BlazorDataGrid_da9ac562.zip

Loader.
Live Chat Icon For mobile
Up arrow icon