Grid - Initial sort does not work with GridForeignColumn

If you set up <GridSortSettings><GridSortColumns><GridSortColumn Field="xxxxx" Direction="SortDirection.Descending" /></GridSortColumns></GridSortSettings> where xxxx is defined in a <GridForeignColumn> the Grid displays but does not contain any rows. Comment out <GridSortColumn> and the row return.

Even though you can order the data in the data source the reason for using the GridSortSettings is to have visual feedback to the user. Is there any way to sort a foreign column?





5 Replies 1 reply marked as answer

RN Rahul Narayanasamy Syncfusion Team November 23, 2020 01:00 PM UTC

Hi Mike, 

Greetings from Syncfusion. 

Query: Grid - Initial sort does not work with GridForeignColumn - the Grid displays but does not contain any rows. Comment out <GridSortColumn> and the row return.  

We have validated your query with the provided information and checked the reported problem at our end. You have mentioned that Grid does not contain any rows while applying initial sorting for ForeignKey column. 

In our end, while applying initial sorting for ForeignKeyColumn, the sorting action takes place based on ForeignKeyField value instead of ForeignKeyValue((i.e.) lookup table value) at our end.  
 
 
For this(the sorting action takes place based on ForeignKeyField value instead of ForeignKeyValue), we have confirmed it is a bug and logged the defect report “Sorting operation does not work properly for foreign key column”. Thank you for taking the time to report this issue 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 upcoming  Volume 4 release, 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.    
    

Please let us know if you have any concerns. 

Regards, 
Rahul 

 



MC Mike Chafin November 23, 2020 04:12 PM UTC

Raul,

I'd like to point out that you may have more than one foreign column with the same Field attribute e.g. 

My Incident 296148
                           
 
                           

                           
                           
                           
                           
                           
                                                                    
                                                                            
For this to work, the ForeignKeyValue attribute has to be included with the  Field attribute.

Sorting on Foreign columns was corrected in release 18.3.0.50 My Incident 300295


RN Rahul Narayanasamy Syncfusion Team November 25, 2020 03:54 AM UTC

Hi Mike, 
 
We have validated your query and we are quite unclear about your  query in last update. Could you please share the below details. It will be helpful to validate and provide a better solution. 
 
  • Whether your reported problem occurs while defining multiple Foreign key column with same Field name?
  • Exact requirement details.
  • Whether did you mention that the sorting problem was resolved in 18.3.0.50 version?
  • Reproduce your problem in the previously provided sample and revert back to us if possible.
  • Share more information about your last update.
 
Regards, 
Rahul 
 



MC Mike Chafin November 25, 2020 03:22 PM UTC

Rahul,

1. I've previously reported, 1. that you could not use multiple with the same field name without an error - incident 296148; 2. That Foreign columns are sorted on the ForeignKeyField and not the ForeignKeyVlaue - incident 300295. 296148 has been resolved in 18.3.0.50 300295 is outstanding 

2. The requirement is being able to set up an initial sort when multiple foreign columns are used and they have the same field reference. How a foreign grid column is sorted is another issue.

3. Your sample code assumes that there is a one to one relationship between the Order and EmployeeId. lookup table. Normally lookups have a many to one relationship. I've attached a new sample which has two lookup tables with a many to one relationship. Also, the Employee lookup table is used twice for lookups on first name and years employed. This means that the Field attribute is used twice. If you try to sort using that field name you get no records. Comment out the  and you will see the records.

4.  Hope this answers your questions

This is not just a sort order issue but a flaw in how sorting is handled when several are included.

Attachment: BlazorApp1FkeySample2026848385_8fdd7cf2.rar


RN Rahul Narayanasamy Syncfusion Team December 1, 2020 04:07 PM UTC

Hi Mike, 

Thanks for sharing the details. 

We have validated your query with the provided information. Yes, the fix the issue “Using multiple GridForeignColumn with same Field name throws exception” mentioned in the incident 296148 was included in our Blazor Weekly patch release (v18.3.0.50). 

In our end, while applying initial sorting for ForeignKeyColumn, the sorting action takes place based on ForeignKeyField value instead of ForeignKeyValue at our end. 

For this(the sorting action takes place based on ForeignKeyField value instead of ForeignKeyValue), the fix for the issue Sorting operation does not work properly for foreign key columnwas postponed to our upcoming  Volume 4 release, 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.     
     

Also, in the provided sample you have provided a wrong value in initial sort settings. So the reported problem occurs. (You have provided EmployeID instead of EmployeeID). You can resolve the problem by changing the value as EmployeeID. 


<GridSortSettings> 
        <GridSortColumns> 
            <GridSortColumn Field="EmployeID" Direction="SortDirection.Descending"></GridSortColumn// you have provided wrong value(provided EmployeID instead of EmployeeID). You can resolve the problem by changing the value as EmployeeID 
        </GridSortColumns> 
    </GridSortSettings> 
<GridColumns> 
         . . . 
         <GridForeignColumn Field=@nameof(Order.EmployeeID) HeaderText="Employee Name" ForeignKeyField="ID" ForeignKeyValue="FirstName" ForeignDataSource="@Employees" Width="150"></GridForeignColumn> 
         . . .  
     </GridColumns> 

Please let us know if you have any concerns. 

Regards, 
Rahul 


Marked as answer
Loader.
Up arrow icon