How to update datasource after edit when using baked in foreign key support

I have a data grid with a column using the foreign key support.

This works great.

            <e-column :field="ColumnFields.Commodity" headerText="Commodity" type="string" width="150"
                      foreignKeyValue="description" foreignKeyField="pickerOptionId" :dataSource="[]" />


And then I set the datasource:

column.edit.params.dataSource = list;


I can successfully edit the column. I'm using batch update and when clicking update it calls my 

beforeBatchSave method: 

:beforeBatchSave="beforeBatchSave"


This is the method that does the actual save to the back end (beforeBatchSave). And the value is changed when the changes reach this method.

When this method returns the call reverts back to the value it had before the update button was clicked (in the toolbar).

So my original data list (the datasource) does not get the updated value.

According to this link, in order to get the behaviour I want I need to set the datasource in the created event. That is challenging as I don't have the data there. It is loaded asynchronously - so I can only set it in a callback kicked off from that method - and this doesn't work. In fact I'm struggling to get any data to appear in the grid at all while using this mechanism for setting the data.


2 Replies

MW Michael Wiles February 16, 2022 11:47 AM UTC

So if I sync the changes from the "batch changes" onto the datasource manually and then refresh the grid it works... I'm going to just go with that for now.



RS Rajapandiyan Settu Syncfusion Team February 16, 2022 02:55 PM UTC

Hi Michael, 
 
Thanks for contacting Syncfusion support. 

If you are updating the data in the server by your own actions without using Grid methods, then you need to bind the updated data to the grid.dataSource property in its success event. From your last update it seems that you have resolved the issue by refreshing the Grid. 

If you face any issue in future, kindly share the below details to validate at our end. 

  1. Share the complete code you have used.
  2. How could you bind the data to Grid? Share the complete code details.
  3. Which type of data(local/remote) you have used? Share the Adaptor details.
  4. Did you update the data in server by your own actions or updating by Grid methods?
  5. Share the video demo of the reported behavior.

Regards, 
Rajapandiyan S 


Loader.
Up arrow icon