Custom Adaptor Additional Parameter is passed to Read but NOT to Insert, Update and Delete

These are the signatures of Read:

public virtual object Read(DataManagerRequest dataManagerRequest, string key = null)

and Insert:

  public virtual object Insert(DataManager dataManager, object data, string key)

When I pass additional parameters:

                <SfGrid TValue="Pupil" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })" Query="@pupilQuery">

I can get them in Read through dataManagerRequest.Params, BUT NOT in Insert, as Params does not exist in DataManager (without Request).

Any assistance please? I am stuck....




1 Reply

NP Naveen Palanivel Syncfusion Team October 31, 2024 06:20 AM UTC

Hi Nikos,

Based on your requirements, we recommend using the CustomAdapter component, which is defined as a component rather than a class instance. This approach allows you to send additional parameters to the CustomAdapter's Read, Insert, Remove, or Update methods, making them accessible inside the component. Please refer to the example and code snippet below for reference.


<SfGrid TValue="Order" ID="Grid" AllowSorting="true" AllowFiltering="true" AllowPaging="true">

    <GridEditSettings AllowDeleting="true"></GridEditSettings>

    <SfDataManager Adaptor="Adaptors.CustomAdaptor">

        <CustomAdaptorComponent Query="Qry"></CustomAdaptorComponent>

    </SfDataManager>

    <GridPageSettings PageSize="8"></GridPageSettings>

    -----

</SfGrid>

 

@code{

    public static List<Order> Orders { get; set; }

    public Query Qry { get; set; } = new Query().AddParams("id", 2).AddParams("str", "23");

}


@code {

    [Parameter]

    [JsonIgnore]

    public RenderFragment ChildContent { get; set; }

 

 

    [Parameter]

 

    public Query Query { get; set; }

 

   

    // Performs Remove operation

    public override async Task<object> RemoveAsync(DataManager dataManager, object value, string keyField, string key )

    {

        //here you can access the query property

        var qry = Query;
---------------

       

    }

    public override async Task<Object?> InsertAsync(DataManager dm, object value, string key)

    {

        //here you can access the query property

        var qry = Query;

-------------

      

    }

    public override async Task<object> UpdateAsync(DataManager dataManager, object value, string keyField, string key)

    {

        //here you can access the query property

        var qry = Query;

-------------

    }

}


Regards,

Naveen


Attachment: BlazorApp_Query_918704d9.zip

Loader.
Up arrow icon