Foreign Key value not resolved when using paging

Hi,

I am using paging. The datasource for the grid contains a odata data source with foreign keys.
Therefore I have added a column with a data source. This works when initially loaded.

When I edit an object and choose a value for the foreign key column then after saving the cell might be empty. There is one precondition that has to be met in order that the cell remains empty. The user must select a value for the foreign key, that is not present (for that column) in the paged list. A reason that might be is that if I use paging then the executed query for that foreign key column filters only for values that are currently visible (e.g. filter only customer ids that are displayed on the current page). This is correct, since I do not want to query for all customers.
But with this feature the issue appears. If on page 1 there exists orders for the customer C1, C2, C3 only, then if I edit an order and select C4 as customer then this cell is empty because the customer C4 was initially not loaded

Currently what works is to refresh the columns:
onActionComplete(args: ActionEventArgs) {
if(args.requestType === 'save')
{
this.grid.refreshColumns();
}
}
Is this the intended behavior?

7 Replies 1 reply marked as answer

RS Rajapandiyan Settu Syncfusion Team December 18, 2020 01:06 PM UTC

Hi Michael, 
 
Greetings from Syncfusion support. 
 
By analyzing your query, we suspect that you were returning only the current page data to the foreignKey column and its dropdown.  
 
When editing the foreignKey column, the dropdown control will be rendered and we need to bind whole data to that dropdown control. 
 
So, we need to return whole data when there is no page query. Please find the below code example and screenshot for your reference. 
 
 
int skip = Convert.ToInt32(queryString["$skip"]);  
int take = Convert.ToInt32(queryString["$top"]);  
----- 
return take != 0 ? new { Items = data.Skip(skip).Take(take).ToList(), Count = data.Count() } : new { Items = data, Count = data.Count() }; 
 
 
 
 
Screenshot #1: Request current page data for the Grid 
 
 
Screenshot #2: request whole data for the foreignKeyColumn 
 
 
Still, if you face the same issue, please share the below details to validate further with this. 
  1. Share the Grid dataSource request in the NetworkTab at initial load
  2. Share the foreignKeyColumn dataSource request in the NetworkTab at initial load.
  3. Video demonstration of the reported behavior.
  4. Share the foreignKey column data request in the NetworkTab while editing the record.
 
Regards, 
Rajapandiyan S


MM Michael Mairegger December 21, 2020 09:30 AM UTC

Dear Mr. Settu,

as foreign key column I have defined the data source X with no further information for paging or filtering. The grid control does the filtering on foreign key columns.
The same date source is used within a ejs-dropdownlist as data source.

Attached there are the request generated on initial load. I have reduced the grid page size to 4, to shorten the requests.


The query for Id eq null is correct since there is no related data in this page.

Lets look at the second query. These are the addressId 408, 410, 413, 418

If I edit one of the displayed items, and coose e.g. the address with the id 310 then after safing the cell stays empty.

Regards,
Michael


SK Sujith Kumar Rajkumar Syncfusion Team December 22, 2020 09:06 AM UTC

Hi Michael, 
 
Your reported problem – “Empty value saved in cell on performing save operation” usually occurs if the saved data is not properly returned from the server back to the Grid. So can you please confirm and share us the following details to validate further on this, 
 
  • Please bind actionBegin event to the Grid and when the event argument - requestType is ‘save’ check whether the proper edited value is sent to the server.
  • Please check if the newly added/edited data is properly returned in the server response as only based on this the Grid data will be updated.
  • Share us the request and response data details from network tab.
  • Sample data bound in the Grid.
 
Let us know if you have any concerns. 
 
Regards, 
Sujith R 



MM Michael Mairegger December 23, 2020 10:22 AM UTC


Response


{"@odata.context":"https://localhost:5001/odata/$metadata#Orders/$entity","Id":2,"DateOfReceipt":"2020-11-30T00:00:00+01:00","DesiredDeliveryDate":"2020-11-30T00:00:00+01:00","PickupDate":null,"IsConfirmed":true,"CustomerId":399,"Amount":1.0,"MeasurementUnitId":2,"Price":700.00,"OrderNumberCustomer":"ff","OriginAddressId":428,"DestinationAddressId":408,"TravelDirection":"Away","CarrierId":null,"CarrierTruck":null,"CarrierInvoiceReceived":false,"PriceCarrier":null}


RS Rajapandiyan Settu Syncfusion Team December 29, 2020 09:38 AM UTC

Hi Michael, 
 
Thanks for your update. 
 
We are tried to reproduce the reported behavior but, it was unsuccessful at our end. The saved record is shown properly in the ForeignKey column. We have prepared a sample for your reference you can get it from the below link. 
 
 
 
Still, if you face the same issue, please share the below details to validate further on this. 
 
  1. Share the complete Grid rendering code you have used.
  2. Share the Syncfusion packages and DLL version.
  3. Are you using complex column field for the foreignKey column?
  4. Video demo of the reported behavior.
 
Regards, 
Rajapandiyan S 


Marked as answer

MM Michael Mairegger January 14, 2021 02:11 PM UTC

Thans for the response. I will try your solution and view you video. Otherwise if the solution does not work I will provide you with the video

Regards,
Michael


RS Rajapandiyan Settu Syncfusion Team January 15, 2021 03:28 AM UTC

Hi Michael, 
 
Thanks for your update. 
 
We will wait to hear from you. 
 
Regards, 
Rajapandiyan S 


Loader.
Up arrow icon