How to apply ODataV4 filter to the SfDropDownList Query parameter

I am using SyncFusion.Blazor v 18.1.0.43

I have a remote ODataV4 API that I have been accessing by passing OData queries to from a service in my Blazor server-side application.

I am migrating to SyncFusion controls and I want to use the DropDownList with the DataAdapter.


Here is my code from the  component's .razor file;

<SfDropDownList id="accountOwner" CssClass="adjust-sf-padding" TValue="string" TItem="Account" @bind-Value="@CreateAccountType.OwnerId" Query="@OwnerIdQuery">
    <SfDataManager Headers="@HeaderData" Url="@ApiAccountsUrl" Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager>
    <DropDownListFieldSettings Text="AccountName" Value="ID"></DropDownListFieldSettings>
</SfDropDownList>


For the OwnerIdQuery in the .razor.cs file, I need to get the equivalent of...

  "$filter=AccountType eq MyAPI.Server.Enums.AccountTypes'Reseller'&$orderby=AccountName&$select=AccountName,Id"

Is there a version of your Query object that can accept the straight QDataV4 query string?



1 Reply

SN Sevvandhi Nagulan Syncfusion Team April 17, 2020 07:37 AM UTC

Hi David, 

Greetings from Syncfusion support. 

We would like to inform you that our query property will support the DataManager query type only. But you can achieve the same functionalities using the query properties such as select, where and Sort.  

In the select query you can select the field name ($select=AccountName,Id). In the where query you can filter the value(AccountType eq MyAPI.Server.Enums.AccountTypes'Reseller') and in the Sort property we can sort the value by passing the specific field name($orderby=AccountName). Kindly refer the below code example and sample for reference, 
 
 
<SfDropDownList TValue="string" TItem="OrderDetails" Placeholder="Select a customer" Query="@Query"> 
    <SfDataManager Url="https://services.odata.org/V4/Northwind/Northwind.svc/Orders" Adaptor="Syncfusion.Blazor.Adaptors.ODataV4Adaptor" CrossDomain=true></SfDataManager> 
    <DropDownListFieldSettings Text="CustomerID" Value="OrderID"></DropDownListFieldSettings> 
</SfDropDownList> 
 
public Query Query = new Query().Select(new List<string> { "CustomerID", "OrderID" }).Where("CustomerID","equal", "TOMSP").Sort("CustomerID").Take(6).RequiresCount(); 
                                     
 
Regards, 
Sevvandhi N 


Loader.
Up arrow icon