Incorrect filtering for columns with equal ForeignKeyValue
Hello,
I have 3 models: Building, Owner and Tenant.
Building has properties: Id, OwnerId, OwnerName, TenantId, TenantName.
Both Owner and Tenant have same properties: Id and Name.
Now, I have a data grid with a list of buildings with 3 columns: Building, Owner and Tenant.
In a nutshell, my Razor-component code is something like this:
<SfGrid TValue="Building" AllowFiltering="true">
<SfDataManager Adaptor="Adaptors.CustomAdaptor" AdaptorInstance="@typeof(BuildingAdaptor)" ></SfDataManager>
<GridColumn Field="@(nameof(Building.Id))"
IsPrimaryKey="true"
IsIdentity="true"
Visible="true"
AllowEditing="false"
Filter="@(new {@@operator = "contains" })">
</GridColumn>
<GridColumn Field="@(nameof(Building.OwnerId))"
Visible="true"
HeaderText="Owner"
ForeignKeyField="Id"
ForeignKeyValue="Name"
DataSource="@Owners"
Filter="@(new {@@operator = "contains" })">
</GridColumn>
<GridColumn Field="@(nameof(Building.TenantId))"
Visible="true"
HeaderText="Tenant"
ForeignKeyField="Id"
ForeignKeyValue="Name"
DataSource="@Tenants"
Filter="@(new {@@operator = "contains" })">
</GridColumn>
</GridColumns>
</SfGrid>
I've implemented a custom filter adaptor using your example in the documentation. For the sake of the project, tenant's and owner's data source contains equal data (not equal objects), because owners can be tenants and vice versa.
Now, let's say I have the following data:
| Building | Owner | Tenant |
| Store | Mike | Alice |
| Shop | Mike | John |
| Station | Jerry | Phil |
| Pawn | Jerry | John |
When I filter the owner column using 'Jerry' I get the following which is correct:
| Building | Owner | Tenant |
| Station | Jerry | Phil |
| Pawn | Jerry | John |
But when I try to filter the tenant column using 'Phil' I get this:
| Building | Owner | Tenant |
| Store | Mike | |
| Shop | Mike | |
| Station | Jerry | Phil |
| Pawn | Jerry |
Strangely though, if I change the property 'Name' in my 'Tenant' model to 'TenantName' (and update the razor markup), everything works fine:
| Building | Owner | Tenant |
| Station | Jerry | Phil |
It seems that when several 'ForeignKeyValue' fields have the same value, filtering doesn't work correctly for all of them but the first.
Considering that I must preserve the properties for Tenants and Owners as is, how can I make the filtering work?
Thank you in advance.
SIGN IN To post a reply.
5 Replies
1 reply marked as answer
KM
Kuralarasan Muthusamy
Syncfusion Team
June 12, 2020 11:38 AM UTC
Hi Madhavacharta,
Thanks for contacting Syncfusion support.
We have tried to reproduce the problem by creating a sample based on the provided code. But the filter action working fine even we provide the same value for several ForeignKeyValue property. We are attaching the sample for your convenience. Please download the sample from the link below,
We need more details to further proceed on this and provide you a solution as early as possible, kindly get back to us with the following details for better assistance.
- If possible, try to reproduce the reported issue in the attached sample and revert back to us.
- Syncfusion package version.
Regards,
Kuralarasan M
MP
Madhavacharta Pande
June 17, 2020 10:14 AM UTC
Thank you for the provided example.
Attachment: BlazorApp1_65623ac6.zip
I have modified it to closely represent my current project: I've added name to Building model and changed its id to int.
But now the search does not work at all.
For it work, I have to replace both Name fields in Tenant and Owner to TenantName and OwnerName.
Like this:
public class Owners
{
public int? Id { get; set; }
public string OwnerName{ get; set; }
}
public class Tenants
{
public int? Id { get; set; }
public string TenantName{ get; set; }
}
Could you please advise what could be the problem here?
Thanks.
Attachment: BlazorApp1_65623ac6.zip
RN
Rahul Narayanasamy
Syncfusion Team
June 18, 2020 05:12 PM UTC
Hi Madhavacharta,
Thanks for the update.
We have validated your query and checked the reported problem at our end. We could not reproduce the reported problem in the sample. We have also provided a video demonstration of the reported problem is not producing at our end. Please find the below video for your reference.
If you are still facing the same problem, could you please share the below details. It will be helpful to validate and provide a better solution.
- Share Syncfusion NuGet version details.
- Video demonstration of the issue.
- Ensure reported problem in the latest version.
Regards,
Rahul
MP
Madhavacharta Pande
June 19, 2020 07:30 AM UTC
Hi Kuralarasan,
Attachment: BlazorApp1_fd3bb87d.zip
Thank you for the video demonstration.
I'm sorry, it seems that I've attached the wrong zip file to my previous reply.
Here is the one that I'm experiencing problems with.
In this example, only 1st and 2nd columns' filters work, but not the 'Owner' or 'Tenant'.
Thank you.
Attachment: BlazorApp1_fd3bb87d.zip
KM
Kuralarasan Muthusamy
Syncfusion Team
June 22, 2020 12:24 PM UTC
Hi Madhavacharta,
Thanks for the sample.
From the given sample, we found that one column Field property and another two columns ForeignKeyValue property value has same value. So, you have faced this issue. We have highlighted this in below code snippet.
|
<GridColumns>
<GridColumn Field=@nameof(Buildings.Name) HeaderText="Building Name" Filter="@(new {@operator = "contains" })" Width="120"></GridColumn>
<GridColumn Field=@nameof(Buildings.OwnerId) HeaderText="Owner" ForeignKeyField=@nameof(Owners.Id) ForeignKeyValue="Name" DataSource="@owners" Filter="@(new {@operator = "contains" })" Width="150"></GridColumn>
<GridColumn Field=@nameof(Buildings.TenantId) HeaderText="Tenant" ForeignKeyField=@nameof(Tenants.Id) ForeignKeyValue="Name" DataSource="@tenants" Filter="@(new {@operator = "contains" })" Width="150"></GridColumn>
</GridColumns> |
And, we would like to inform that we have considered it as a bug and logged defect report for the same “Foreign key column filtering is not working when Field and ForeignKeyValue has the same value”. 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 2020 Volume 2 Release scheduled at the end of June, 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.
Feedback Link : https://www.syncfusion.com/feedback/15402
Till then we appreciate your patience.
Regards,
Kuralarasan M
Marked as answer
SIGN IN To post a reply.
- 5 Replies
- 3 Participants
- Marked answer
-
MP Madhavacharta Pande
- Jun 11, 2020 04:13 PM UTC
- Jun 22, 2020 12:24 PM UTC