Unable to do server side filter dropdown control

Dear Team,

Regarding the dropdown list control, we are unable to do the server sider filter in the razor pages

Kindly advice.

regards
Prasad

1 Reply 1 reply marked as answer

BC Berly Christopher Syncfusion Team November 2, 2020 12:22 PM UTC

Hi Prasad, 
  
Greetings from Syncfusion support. 
  
We have prepared the sample based on the requested requirement that perform the server-side filtering using URL adaptor in the ASP.NET Core razor pages and attached it below. 
  
[index.cshtml] 
 
@Html.AntiForgeryToken() 
 
<div id='url-data' class='col-lg-6' style='padding-top:15px'> 
    <div class='content'> 
        <ejs-dropdownlist id="country" placeholder="Select a Country" allowFiltering="true"> 
            <e-data-manager adaptor="UrlAdaptor" url="/Index?handler=DataSource" crossDomain="true"></e-data-manager> 
            <e-dropdownlist-fields value="ShipCountry"></e-dropdownlist-fields> 
        </ejs-dropdownlist> 
    </div> 
</div> 
<script> 
    document.addEventListener("DOMContentLoaded", function () { 
        var drop = document.getElementById("country"); // Take the instance for the DropDownList 
        drop.ej2_instances[0].dataSource.dataSource.headers = [{ 'XSRF-TOKEN': $("input:hidden[name='__RequestVerificationToken']").val() }]; 
    }) 
</script> 
[index.cshtml.cs] 
 
public JsonResult OnPostDataSource([FromBody]Data dm, string text) 
        { 
            var val = OrdersDetails.GetAllRecords(); 
            var Data = val.ToList(); 
            var count = val.Count(); 
            if (dm.where != null) 
            { 
                Data = (from cust in Data 
                        where cust.ShipCountry.ToLower().StartsWith(dm.@where[0].value.ToString()) 
                        select cust).ToList(); 
            } 
            if (dm.take != 0) 
                Data = Data.Take(dm.take).ToList(); 
            return new JsonResult(Data); 
        } 

  
Please find the sample from the below link. 
  
If we misunderstood your query,  please share the detials of the adaptor code or issue reproducing sample that will help us to check and proceed further at our end.  
  
Regards, 
Berly B.C 


Marked as answer
Loader.
Up arrow icon