Custom DataAdaptor with additonal params

Hi guys.

I have SfGrid with custom OrdersDataAdaptor. I would like to show orders with "from date" and "to date" condition. Dates from and to are are set in SfDatePicker.

ReadAsync has additionalParameters but can not find information where can I set this. 

How can I put additionalParameter to OrdersDataAdaptor.ReadAsync method? Is it possible?

Has DataManager any pre-load data event whe I can put some additionals parameters (date from, date to, order status)?

Or, how can I put additional WhereFilter to DataManagerRequest?


5 Replies

BL Balamurugan Lakshmanan Syncfusion Team September 15, 2023 06:59 AM UTC

Hi Jacek,


Greeting from Syncfusion support.


We have already discussed this topic in our UG documentation. To send an additional parameter to the data request, use the AddParams method of Query class. Assign the Query object with additional parameters to the DataGrid’s Query property. Kindly refer the attached the below attached UG documentation link to resolve your issues.


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


Please get back to us if you have further queries.



JC Jacek Czapla September 15, 2023 12:24 PM UTC

Thanks. Works fine.



MS Monisha Saravanan Syncfusion Team September 18, 2023 07:35 AM UTC

Hi Jacek,


We are glad to hear that the reported issue has been resolved at your end. Kindly get back to us if you have further queries. As always we will be happy to assist you.



SG Sven G November 6, 2023 08:06 PM UTC

How to add dynamic Query parameters based on selected/currently edited item?



PS Prathap Senthil Syncfusion Team November 7, 2023 10:54 AM UTC

Hi Sven,

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,

Prathap S


Attachment: DataGridQuery_ef4a9f67.zip

Loader.
Up arrow icon