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 to remove $count from ODataV4Adaptor request?

When loading the data for a grid inside the DetailTemplate of a hierarchical grid we would like to remove the "count" option from the request as it adds an unnecessary delay.

The SfDataManager is configured as follows:

<SfDataManager Adaptor="Adaptors.ODataV4Adaptor"
               Headers="@Headers"
               Url="@($"https://localhost:123/gateway/odata/endpoint?someId={SomeId}")" />

This results in a call with the count option:

https://localhost:123/gateway/odata/endpoint?someId=132$count

As a result 2 database queries are triggered.

How can we specify that the $count option is not needed?


2 Replies

NP Naveen Palanivel Syncfusion Team December 12, 2022 04:53 PM UTC

Hi Niels,  


We are currently Validating  the reported query at our end and we will update the further details shortly. Until then we appreciate your patience.


Regards,

Naveen Palanivel



NP Naveen Palanivel Syncfusion Team December 27, 2022 03:02 AM UTC

Hi Niels,


Sorry for the delay


We suspect that you want to customize incoming data request and data response. If yes, then we have option to override internal methods of ODataV4Adaptor class. So we suggest you to check your scenario by overriding the ProcessQuery and  ProcessResponse method of ODataV4Adaptor class. Inside this ProcessQuery and  ProcessResponse method you can perform your custom customization.


Please refer and use as like the code below,

 

<SfGrid @ref="Grid" Height="100%" Width="100%" ...>

    ...

   <SfDataManager  @ref="DataManagerRef" Url="/weatherforecast" CrossDomain="true" Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager>

</SfGrid>

 

@code {

    SfGrid<WeatherForecast> Grid;

    public static SfDataManager DataManagerRef { getset; }

    protected override void OnAfterRender(bool firstRender)

    {

        if (firstRender) {

                DataManagerRef.DataAdaptor = new NewODataClass(DataManagerRef);

        }

        base.OnAfterRender(firstRender);

    }

    public class NewODataClass : ODataV4Adaptor

    {

        public NewODataClass(DataManager dm) : base(dm)

        {

        }

        public override object ProcessQuery(DataManagerRequest queries)

        {

 

            RequestOptions ActualReturnValue = (RequestOptions)(base.ProcessQuery(queries));

 

                                 //you can customize the query here

            return ActualReturnValue;

        }

    }

 

}

 

Please check the above suggestion and try this from your side.


Regards,

Naveen


Loader.
Up arrow icon