Search "contains" doesn't seem to work.

Hello there, I have a multi-select dropdown and I'm not able to get contains to work. Any idea what I could be doing wrong?

This is my code in Razor page:

 @Html.EJS().MultiSelect("riskTreatment").Placeholder("- Select risk type(s) -").PopupHeight("200px").Width("300px").DataSource(dataManger =>
     dataManger.Url("/Manage/TreatmentControlsDatasource").Adaptor("UrlAdaptor").CrossDomain(true)).FilterType(Syncfusion.EJ2.DropDowns.FilterType.Contains).AllowFiltering(true).Fields(new Syncfusion.EJ2.DropDowns.MultiSelectFieldSettings
        {
            Text = "ControlFullName",
            Value = "Id"
        }).Render()

It just seems to do "Starts with" only.

Thanks in advance.


1 Reply

SP Sureshkumar P Syncfusion Team May 11, 2020 08:46 AM UTC

Hi Georg, 
 
Greetings from Syncfusion support. 
 
Based on your shared information. We suspect that you want to search the data with contains filter type. When you use the local adaptor, we suggest you handle the server-side filtering action with contains key instead of startswith key.  
 
Kindly refer the code example. 
 
[index.cshtml] 
 
@(Html.EJS().MultiSelect("OrganisationStaffId").Placeholder("Select a staff").DataSource(dataManger => 
     dataManger.Url("/Home/UrlDatasource").Adaptor("UrlAdaptor").CrossDomain(true)).FilterType(Syncfusion.EJ2.DropDowns.FilterType.Contains).AllowFiltering(true).Fields(new Syncfusion.EJ2.DropDowns.MultiSelectFieldSettings 
        { 
            Text = "ShipCountry", 
            Value = "OrderID" 
        }).Render()) 
 
[controller.cs] 
 
public ActionResult UrlDatasource(Data dm) 
        { 
            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().Contains(dm.@where[0].value.ToString()) 
                        select cust).ToList(); 
            } 
            if (dm.take != 0) 
                Data = Data.Take(dm.take).ToList(); 
            return Json(Data); 
        } 
 
We created the sample based on your requirement. please refer the sample here: https://www.syncfusion.com/downloads/support/directtrac/general/ze/DropdownlistURLAdaptor2030473394  
 
Could you please check the above sample and let us know whether this is fulfilling your requirement or get back to us if you need further assistance. 
 
Regards, 
Sureshkumar P 


Loader.
Up arrow icon