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?
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.
Thanks. Works fine.
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.
How to add dynamic Query parameters based on selected/currently edited item?
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.
|
<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"); } [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