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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Excel Filtering on ForeignKey Column foreignKeyValue

Thread ID:

Created:

Updated:

Platform:

Replies:

147271 Sep 4,2019 06:05 PM UTC Sep 11,2019 02:15 PM UTC Angular - EJ 2 5
loading
Tags: Grid
Kelly Harrison
Asked On September 4, 2019 06:27 PM UTC

So I know the following is true:
I'd like to know if there is a workaround to this limitation.  Using the foreignKeyField seems like a use case that would be a lot less prevalent than using foreignKeyValue.  I'd like to be able to use the Excel filtering, in particular the Search field on the Excel dropdown.  However, due to the limitation above, I get an ODATA error.

Manivel Sellamuthu [Syncfusion]
Replied On September 5, 2019 04:15 PM UTC

  
Hi Kelly, 

Thanks for contacting us. 

By default in Grid, Sorting and Grouping will be performed based on foreignKey field only, Since it is the unique value that maps the two values and foreignKeyValue column may have a duplicate values. Due to the above reason ForeignKeyField value is used for Grouping and sorting.  

So please explain more about your requirement that will help us to provide better solution as soon as possible. 

Regards, 
Manivel 
 


Kelly Harrison
Replied On September 5, 2019 05:49 PM UTC

Now I'm not so sure that's what's going on.  Here's the relevant portion of my model:

    public partial class ProductInventory
    {
        public int ProductInventoryId { get; set; }
        public int ProductId { get; set; }
        public int LocationId { get; set; }
        public int Quantity { get; set; }
        public DateTime CreatedDate { get; set; }
        public DateTime ModifiedDate { get; set; }
        public virtual Location Location { get; set; }
        public virtual Product Product { get; set; }
    }

    public partial class Product
    {
        public int ProductId { get; set; }
        public string Material { get; set; }
        public string MaterialDesignation { get; set; }
        public string Notes { get; set; }

        public virtual ICollection ProductInventories { get; set; }
        public virtual ICollection Transactions { get; set; }
    }

OData config from WebApiConfig.cs:

            ODataModelBuilder builder = new ODataConventionModelBuilder();
            builder.EntitySet("Products");
            builder.EntityType().HasKey(p => p.ProductId);

            builder.EntitySet("Locations");
            builder.EntityType().HasKey(l => l.LocationId);

            builder.EntitySet("Transactions");
            builder.EntityType().HasKey(t => t.TransactionId);

            builder.EntitySet("ProductInventories");
            builder.EntityType().HasKey(p => p.ProductInventoryId);
            builder.EntityType().ContainsRequired(p => p.Product);

            config.Select().Expand().Filter().OrderBy().MaxTop(10000).Count();
         
When I try to search in the Excel filter bar, it hangs and I get the error below:




The url being generated by the grid is this:
https://localhost:44349/odata/Products/?$apply=groupby((ProductId))&$filter=contains(tolower(Material),%274%27)



Thavasianand Sankaranarayanan [Syncfusion]
Replied On September 10, 2019 12:52 PM UTC

Hi Kelly, 

Thanks for the update. 

From that, we suspect that you have not handled the $apply query in the server side, So please ensure that in your end. If you still face the issue, please share us the server side code and data-manager code, to validate further. 

Regards, 
Thavasianand S. 


Kelly Harrison
Replied On September 10, 2019 04:00 PM UTC

It's a generic Web API OData controller.  $apply should work out of the box.

        // GET: odata/Products
        [EnableQuery(MaxTop = 1000)]
        public IQueryable GetProducts()
        {
            return db.Products;
        }

The following url works fine:


Things only break when the filter parameter is added.  Likewise, the filter parameter by itself works without issue.

I've opened an incident and I'll post the solution we come up with here.

Thavasianand Sankaranarayanan [Syncfusion]
Replied On September 11, 2019 02:15 PM UTC

Hi Kelly, 

Please followup on that incident for further updates.  

Regards, 
Thavasianand S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon