How to create a Column Filter DropDown for a list of ENUM values

I am using SyncFusion.Blazor v18.1.0.45

I have a grid with a FilterTemplate described below. When I first load the component, I do not see the dropdownlist appear below the column header. I have attached a screenshot showing the issue.

Once I move to another component and then come back to it, I can then see the dropdown list as expected. 
 


Here is my code to build the string array;

     protected string[] AccountTypeValues { get; set; } = Enum.GetNames(typeof(AccountTypes));

Here is the enum;

    public enum AccountTypes
    {
        Customer = 0,
        Reseller = 1,
        Provider = 2,
    }
                  
Here is the column from the grid;

   
                              
                           
                           
                       

           
           
       
   

Here is the HandleChangeAccountTypeFilter method;

        protected void HandleChangeAccountTypeFilter(ChangeEventArgs args)
        {
            if (args.Value == "All")
            {
                Grid.ClearFiltering();
            }
            else
            {
                Grid.FilterByColumn("AccountType", "equal", args.Value);
            }
        }


I have attached a screenshot to show the result.

Note that I can filter the list by typing text into the Account Name or Account Owner filter boxes with no problem.

Any ideas?

 





Attachment: SyncFusion_Screenshots_54142f72.zip

6 Replies

DA David Adler April 22, 2020 11:29 PM UTC

Well, I guess I can't paste HTML code in the editor. 

Attached is my .razor file for the grid.


Attachment: AccountListComponent_04222020_72472881.zip


DA David Adler April 22, 2020 11:36 PM UTC

One other thing, When the DropDownList does appear and I select one of the choices, it does not filter the list. I can set a breakpoint in the 

 Grid.FilterByColumn("AccountType", "equal", args.Value)

.. line and I can see the args.Value has the correct string value (i.e. Reseller). But it just returns with "No Records Found" and the dropdownlist is missing again from the column filter section.






VN Vignesh Natarajan Syncfusion Team April 23, 2020 11:34 AM UTC

Hi David,  
 
Greetings from Syncfusion support. 
 
Query1: “ When I first load the component, I do not see the dropdownlist appear below the column header. I have attached a screenshot showing the issue 
 
We have validated the defect you have initiated with us. Thank you for taking the time to report this issue “Template is not rendered during the initial load” and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and including the defect fix in our next upcoming patch release which is expected to be rolled out on or before 29th April 2020. 
 
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. 
 
 
Till then we appreciate your patience.  
 
Query2: “One other thing, When the DropDownList does appear and I select one of the choices, it does not filter the list. I can set a breakpoint in the  
 
We have analyzed the issue and we are not able to reproduce the reported issue (no record to display is returned) at our end. While selecting a value from dropdown, we are able to filter the record without any error. Please find the sample from below  
 
 
If you are still facing the issue, kindly share more details about issue you are facing or try to reproduce the reported issue in above sample and revert back to us.  
 
Regards,
Vignesh Natarajan
 



DA David Adler April 23, 2020 02:30 PM UTC

Thanks you for the reply and I look forward to the next update. 

In reference to the filter not actually working on the back end data service; the problem is the output of the Grid.FilterByColumn() method. My ODatav4 API (Microsoft ASP.NET Core 3.1 with Microsoft's ODataV4 implementation) is throwing a Status 400 from the $filter query.

The AccountType is an ENUM. In Postman, I can send a GET with the following filter;

 $filter=(AccountType eq EII.CDAPI.Server.Enums.AccountTypes'Reseller')&$skip=0&$top=10

and get the expected results.

However, the output of the Grid.FilterByColumn() method wraps everything inside the parentheses in single quotes, as follows;

 $filter=('AccountType eq EII.CDAPI.Server.Enums.AccountTypes'Reseller'')&$skip=0&$top=10

Here is the actual filter line captured in Fiddler;

/v1/accounts?$count=true&$filter=(AccountType%20eq%20'EII.CDAPI.Server.Enums.AccountTypes%27Reseller%27')&$skip=0&$top=10

Which results in a status 400 error complaining about the extra single quotes.

Here is my call to the Grid.FilterByColumn method;

                Grid.FilterByColumn("AccountType", "equal", $"EII.CDAPI.Server.Enums.AccountTypes'{args.Value}'", null, true);

Any idea how to work around this?





VN Vignesh Natarajan Syncfusion Team April 27, 2020 03:18 PM UTC

Hi David,  
 
Sorry for the inconvenience caused. 
 
Query: “Which results in a status 400 error complaining about the extra single quotes 
 
From your query we understand that you are facing issue while filtering the record with ENUM value and ODataV4 adaptor. Currently we are validating your query, we need some more time to analyze the issue further. So we will update you the further details by 29th April 2020.   
 
Till then we appreciate your patience. 
 
Regards, 
Vignesh Natarajan 



VN Vignesh Natarajan Syncfusion Team May 4, 2020 11:56 AM UTC

Hi David, 
 
Sorry for the delay in getting back to you.  
 
Thank you for requesting this feature and helping us define it. We are always trying to make our products better and feature requests like yours are a key part of our product growth efforts. We have added this feature “Support to provide filtering enum values using ODataV4 adaptor” request to our database. You can now track the current status of this feature request here. At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technological feasibility, and customer interest. We will let you know when this feature is implemented. 
 
 
 You can also communicate with us regarding the open features any time using our Feature Report page. 
 
Regards,
Vignesh Natarajan
 
 


Loader.
Up arrow icon