Params sent to UpdateAsync(DataManager dataManager

Hi,


When using a CustomAdaptor, in the method 

UpdateAsync(DataManager dataManager..) how could we access params?


1 Reply

RS Renjith Singh Rajendran Syncfusion Team August 25, 2021 05:42 AM UTC

Hi John, 

Greetings from Syncfusion support. 

We suggest you to use CustomAdaptor as Component feature for this scenario. And now you can fetch the Query AddParams value using Grid’s ref. 

We have also prepared a sample based on this scenario for your convenience. Please download the sample from the link below, 

Please refer the codes below, 

 
<SfButton OnClick="OnClick">Modify query</SfButton> 
 
<SfGrid @ref="GridInstance" ... Query=@GridQuery> 
    <SfDataManager Adaptor="Adaptors.CustomAdaptor"> 
        <CustomAdaptor GridRef=@GridInstance></CustomAdaptor> 
    </SfDataManager> 
    ... 
</SfGrid> 
 
@code{ 
    public string ParamValue = "original"; 
    public Query GridQuery { getset; } 
    SfGrid<Order> GridInstance; 
    public void OnClick() 
    { 
        //Example code on how to modfiy AddParams query 
        GridInstance.Query.Queries.Params["sfgrid"] = "changed"; 
    } 
    protected override void OnInitialized() 
    { 
        GridQuery = new Query().AddParams("sfgrid", ParamValue); 
    } 
} 

[CustomAdaptor.razor] 

        [Parameter]        public Syncfusion.Blazor.Grids.SfGrid<OrderGridRef{ getset; }        ...        // Performs Update operation        public async override Task<object> UpdateAsync(DataManager dm, object value, string keyField, string key)        {            //fetch param value by using below code            var paramvalue = GridRef.Query.Queries.Params.FirstOrDefault().Value;            ...            return value;        }

Please get back to us if you need further assistance. 

Regards, 
Renjith R 


Loader.
Up arrow icon