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

Not Results Found When using UrlAdapter

I'm trying to use a Blazor SfDropDownList with the URL adapter to a custom (non web api) api hosted in the same project. The Dropdown list is returning "No results found" and the browser is correctly calling the URL and returning the payload according to the documentation.

How do I get the SfDropDownList to show data from a custom URL?

Payload returned from the browser network panel:

{

"result":[
  {"value":"sample 1","text":"sample 1"},
  {"value":"sample 2","text":"sample 2"}
],
"count":19
}

Blazor Code:

<SfDropDownList TValue="string" TItem="ListItemStringOnly" PopupHeight="230px" Placeholder="Select a type" @bind-Value="EquipmentType">
    <SfDataManager Url="@Url" Adaptor="Adaptors.UrlAdaptor" CrossDomain=true Offline="true"></SfDataManager>
<DropDownListFieldSettings Text="Text" Value="Value"  />  <!-- tried lower case text and value as well -->
</SfDropDownList>

@code {
    string EquipmentType { get; set; }
    string Url;

    protected override async Task OnInitializedAsync()
    {
     Url = new EquipmentTypeLookup().ToReplyUrl();
   
    }
}
 public class ListItemStringOnly
    {
        public string Value { get; set; }
        public string Text { get; set; }

        public ListItemStringOnly(string val) {
            Value = val;
            Text = val;
        }
    }

This is what is shown in the ui (non formatted):






4 Replies

SP Sureshkumar P Syncfusion Team January 27, 2023 08:44 AM UTC

Hi Sam,

To resolve this, we recommend that you set the Text and Value properties to use small letters as the first character instead of capital letters. This should help ensure that the network results match the small letter case. For reference, you can find the necessary code changes on below.

<SfDropDownList TValue="string" TItem="ListItemStringOnly" PopupHeight="230px" Placeholder="Select a type" @bind-Value="EquipmentType">

    <SfDataManager Url="@Url" Adaptor="Adaptors.UrlAdaptor" CrossDomain=true Offline="true"></SfDataManager>

<DropDownListFieldSettings Text="text" Value="value"  />  <!-- tried lower case text and value as well -->

</SfDropDownList>

 

@code {

    string EquipmentType { get; set; }

    string Url;

 

    protected override async Task OnInitializedAsync()

    {

     Url = new EquipmentTypeLookup().ToReplyUrl();

  

    }

}


Regards,

Sureshkumar P



SA Sam January 27, 2023 03:05 PM UTC

I tried that before posting and it doesn't work either.  It always shows "No records found".  Can you confirm that the dropdown actually works with the UrlAdapter?  I read the docs and my example should work according to them but doesn't.



SA Sam January 27, 2023 03:42 PM UTC

Here is a reproduction.  I downloaded the Blazor WASM template (here), added a simple service and updated the index page to use two drop downs with the two casing.  Both show No records found and you'll see the network calls returning exactly what the docs say they should return.


Source code for the repro: https://github.com/sbosell/syncfusion-dropdown-repro



SP Sureshkumar P Syncfusion Team February 7, 2023 11:31 AM UTC

Sam, we suggest you pass the returned response with RequiresCounts attribute value as true or if the RequiresCounts attribute is not present on your returned response data then you can pass directly the response with datasource as an array of objects as mentioned in the code example.

Find the returned response controller code here:

public object Post([FromBody]DataManagerRequest dm)

        {

            if (order.Count == 0)

            {

                BindDataSource();

            }

            IEnumerable DataSource = order.ToList();

            if (dm.Search != null && dm.Search.Count > 0)

            {

                DataSource = DataOperations.PerformSearching(DataSource, dm.Search);  //Search

            }

            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting

            {

                DataSource = DataOperations.PerformSorting(DataSource, dm.Sorted);

            }

            if (dm.Where != null && dm.Where.Count > 0) //Filtering

            {

                DataSource = DataOperations.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);

            }

            int count = DataSource.Cast<Orders>().Count();

            if (dm.Skip != 0)

            {

                DataSource = DataOperations.PerformSkip(DataSource, dm.Skip);   //Paging

            }

            if (dm.Take != 0)

            {

                DataSource = DataOperations.PerformTake(DataSource, dm.Take);

            }

            return dm.RequiresCounts ? new { result = DataSource, count = count } : DataSource;

 

        }


Find the sample in the attachment:


Attachment: URL_e1f5fff3.zip

Loader.
Live Chat Icon For mobile
Up arrow icon