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 send multiple key in method RemoveAsync in DataManager

How to add many parameters (for example, two parameters id=2 and str='23') to a method RemoveAsync in 

DataManager?


6 Replies 1 reply marked as answer

NP Naveen Palanivel Syncfusion Team January 20, 2023 02:09 AM UTC

Hi Kavit,


Thank you for reaching out to Syncfusion support.


We have already discussed your requirement in our documentation, which can be accessed from the below link,

Documentation: https://blazor.syncfusion.com/documentation/datagrid/custom-binding#how-to-pass-additional-parameters-to-custom-adaptor



Please let us know if you have any concerns.


Regards,

Naveen Palanivel



KA kavit January 20, 2023 06:39 AM UTC

Query, only for method ReadAsync.


NP Naveen Palanivel Syncfusion Team February 3, 2023 05:04 AM UTC

Hi Kavit


Sorry for the delay,


We have reviewed your request and understood that you would like to pass a query to the RemoveAsync method in DataManager. To better meet your requirements, we recommend creating a Custom Adaptor as a separate component and passing the query as a parameter to the RemoveAsync method. For more details on how to create a custom Adaptor, please refer to the following documentation


Documentation : https://blazor.syncfusion.com/documentation/datagrid/custom-binding#custom-adaptor-as-component


Please let us know if you have any concerns.


Regards,

Naveen Palanivel



KA kavit February 3, 2023 08:23 AM UTC

In method insert, come Only one parameter, primary key, in value object.



VN Vignesh Natarajan Syncfusion Team February 20, 2023 09:46 AM UTC

Hi Kavit,


Sorry for the delay in getting back to you.


Query: “In method insert, come Only one parameter, primary key, in value object.


Once the CustomAdaptor component is defined as a component instead of a Class instance, then additional parameters can be sent to CustomAdaptor Ready, Insert, Remove or Update methods as Parameters and accessed inside it. Refer to the below code example.


<SfGrid TValue="Order" ID="Grid" AllowSorting="true" AllowFiltering="true" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })">

    <SfDataManager Adaptor="Adaptors.CustomAdaptor">

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

    </SfDataManager>

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

    <GridEditSettings AllowEditing="true" AllowDeleting="true" AllowAdding="true" Mode="@EditMode.Normal"></GridEditSettings>

    <GridColumns>

        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Center" Width="140"></GridColumn>

        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>

        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Width="150"></GridColumn>

    </GridColumns>

</SfGrid>

 

@code {

  

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

  

}

 

……

 

[CustomAdaptorComponent.razor]

 

@code {

    [Parameter]

    [JsonIgnore]

    public RenderFragment ChildContent { get; set; }

 

    [Parameter]

    public Query Query { get; set; }

 

. . . . . . . .

    // Performs Insert operation

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

    {

        //here you can access the query property

        var qry = Query;

. . . . . .

    }

 

    // Performs Remove operation

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

    {

        //here you can access the query property

        var qry = Query;

. . . . . . . .

        return value;

    }

   

    // Performs Update operation

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

    {

        //here you can access the query property

        var qry = Query;

. . . . . . .

       

        return value;

    }


Kindly refer to the sample in the attachments for your reference. Please get back to us if you have further queries.


Regards,

Vignesh Natarajan


Marked as answer

KA kavit February 20, 2023 10:21 AM UTC

Thank you. Your example helped me.


Loader.
Live Chat Icon For mobile
Up arrow icon