Filter using both text and value field

10 Mar 20222 minutes to read

The AutoComplete data can be filtered based on both text and value fields using predicate of dataManager through filtering event. The filtered data can be again updated through updateData method.

@using Newtonsoft.Json;

<div id='List' class='col-lg-6' style='padding-top:15px'>
    <div class='content'>
        <ejs-autocomplete dataSource="" showClearButton="false" id="project" filtering="filtering" itemTemplate="<span class='item'><span class='name'>${Name}</span>-<span class='code'>${Code}</span></span>">
            <e-autocomplete-fields  Text ="Name" Value ="Code"></e-autocomplete-fields>
    function filtering(e) {
        var predicate = new'Name', 'contains', e.text, true);
        predicate = predicate.or('Code', 'contains', e.text);
        var query = new;
        query = (e.text !== '' && e.value !== '') ? query.where(predicate) : query;
        e.updateData(@Html.Raw(JsonConvert.SerializeObject(, query);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WebApplication1.Models;

namespace WebApplication1.Controllers
    public class AutoCompleteController : Controller
        public ActionResult filtering()
   = new Countries().CountriesList();
            return View();