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. Image for the cookie policy date

How get object from RemoveAsync, InsertAsync, UpdateAsync when implement DataAdaptor

I using SfDataManager Adaptor="Adaptors.CustomAdaptor" AdaptorInstance="typeof(...)" override methods (RemoveAsync, InsertAsync, UpdateAsync). How do i get the object that each of these methods returns&


7 Replies 1 reply marked as answer

MS Monisha Saravanan Syncfusion Team January 4, 2023 01:24 PM UTC

Hi Kavit,


Greetings from Syncfusion support.


We suspect that you are expecting to get the changed/updated record details. If so we would like to inform that Action complete event will be triggered after performing CRUD operation and we can get details in the action event argument. Kindly check the below UG for your reference.


Reference: https://blazor.syncfusion.com/documentation/datagrid/events#onactioncomplete


If we misunderstood your query then kindly share the below details to proceed further at our end.


  1. Share us some more details about your exact requirement in detail.
  2. Share us the entire Grid code snippet.
  3. Share us the video demonstration of the issue.
  4. If possible share us an simple issue reproduceable sample.


Above requested details will be very helpful in validating the reported query at our end and provide solution as early as possible.


Regards,

Monisha



KA kavit January 4, 2023 01:46 PM UTC

In  method OnActionComplete not come new value Id.


Attachment: OnActionCompleteForSfTeem_cf1eee7.zip


KA kavit January 4, 2023 01:46 PM UTC

Record video


Attachment: OnComplete_20d146b4.7z


MS Monisha Saravanan Syncfusion Team January 5, 2023 07:35 AM UTC

Hi Kavit,


We suggest you to use below solution to overcome the reported issue. Here we have customized the data from the parameter so that we can get the customized data at our Action event argument. Kindly check the attached code snippet and sample for your reference.


public override async Task<object> InsertAsync(DataManager dataManager, object data, string key)

        {

            //Order order = new Order { CustomerID=(data as Order).CustomerID, OrderID=123, Freight=123};

            //Orders.Add(order);

            //return order;

            

            Order val = data as Order;

            val.OrderID = 123;

            val.Freight = 123;

            Orders.Add(data as Order);

            return data;

        }


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/OnActionCompleteForSfTeem1945237710.zip


Please let us know if you have any concerns.


Regards,

Monisha


Marked as answer

KA kavit January 5, 2023 08:16 AM UTC

Yes, your example works. Yet. It became interesting to me Why it is impossible to return new object?



KA kavit January 5, 2023 09:52 AM UTC

// I got it right?

var test = new TestRef();

ChangeTestStr(test);

PrintTestStr(test);

void ChangeTestStr(TestRef test)

{

    test.TestStr = "123";

}

void PrintTestStr(TestRef test)

{

    Console.WriteLine(test.TestStr);

}

public class TestRef

{

    public string TestStr { get; set; }

}



MS Monisha Saravanan Syncfusion Team January 6, 2023 11:29 AM UTC

Hi Kavit,


We would like to inform that the InsertAsync method will update the Grid once it is rendered so the newly returned values will not be reflected in ActionComplete. So we suggest you to make use of existing variable to reflect the changes in ActionComplete event.


Please let us know if you have any concerns.


Regards,

Monisha


Loader.
Up arrow icon