AspNet4/Mvc/DataFiltering/Controllers/OrderController.cs
/// <summary>
/// This action is called when user clicks on "Apply" button in FilterBar or other data-filtering widget
/// </summary>
/// <returns>An ActionResult object that contains a partial view with the filtered result set.</returns>
This action is called when user clicks on "Apply" button in FilterBar or other data-filtering widget
This action is called when user clicks on " Apply " button in FilterBar or other data - filtering widget
[HttpPost]
        [Route("models/{modelId}/fetch")]
        public async Task<ActionResult> ApplyQueryFilter(string modelId)
        {
            Request.InputStream.Position = 0;
            await _eqManager.ReadRequestContentFromStreamAsync(modelId, Request.InputStream);
            var orders = _dbContext.Orders
                      .Include(o => o.Customer)
                      .Include(o => o.Employee)
                      .AsQueryable();
            var clientData = (IDictionary<string, object>)_eqManager.ClientData;
            var text = clientData != null && clientData.TryGetValue("text", out object value)
                ? (string)value : "";
            if (!string.IsNullOrEmpty(text)) {
                var options = new FullTextSearchOptions
                {
                    Depth = 2,
                    Filter = (propInfo) =>
                    {
                        if (propInfo.DeclaringType == typeof(Order)) {
                            return propInfo.PropertyType == typeof(Customer) || propInfo.PropertyType == typeof(Employee);
                        }
                        else if (propInfo.PropertyType == typeof(string)) {
                            if (propInfo.DeclaringType == typeof(Customer)) {
                                return propInfo.Name == "CompanyName" || propInfo.Name == "Country";
                            }
                            else if (propInfo.DeclaringType == typeof(Employee)) {
                                return propInfo.Name == "FirstName" || propInfo.Name == "LastName";
                            }
                        }
                        return false;
                    }
                };
                orders = orders.FullTextSearchQuery<Order>(text, options);
            }
            orders = orders
             .DynamicQuery<Order>(_eqManager.Query);
            var list = orders.ToPagedList(_eqManager.Chunk.Page, 15);
            ViewData["Text"] = text;
            return View("_OrderListPartial", list);
        }
[ HttpPost ] [ Route ( " " ) ] public async Task < ActionResult > ApplyQueryFilter ( string modelId ) { Request . InputStream . Position = 0 ; await _eqManager . ReadRequestContentFromStreamAsync ( modelId , Request . InputStream ) ; var orders = _dbContext . Orders . Include ( o => o . Customer ) . Include ( o => o . Employee ) . AsQueryable ( ) ; var clientData = ( IDictionary < string , object > ) _eqManager . ClientData ; var text = clientData != null && clientData . TryGetValue ( " " , out object value ) ? ( string ) value : " " ; if ( ! string . IsNullOrEmpty ( text ) ) { var options = new FullTextSearchOptions { Depth = 2 , Filter = ( propInfo ) => { if ( propInfo . DeclaringType == typeof ( Order ) ) { return propInfo . PropertyType == typeof ( Customer ) || propInfo . PropertyType == typeof ( Employee ) ; } else if ( propInfo . PropertyType == typeof ( string ) ) { if ( propInfo . DeclaringType == typeof ( Customer ) ) { return propInfo . Name == " " || propInfo . Name == " " ; } else if ( propInfo . DeclaringType == typeof ( Employee ) ) { return propInfo . Name == " " || propInfo . Name == " " ; } } return false ; } } ; orders = orders . FullTextSearchQuery < Order > ( text , options ) ; } orders = orders . DynamicQuery < Order > ( _eqManager . Query ) ; var list = orders . ToPagedList ( _eqManager . Chunk . Page , 15 ) ; ViewData [ " " ] = text ; return View ( " " , list ) ; }
This action is called when user clicks on "Apply" button in FilterBar or other data-filtering widget
This action is called when user clicks on " Apply " button in FilterBar or other data - filtering widget
//read full-text search text // filter to use search for string fields we chose
An ActionResult object that contains a partial view with the filtered result set.
An ActionResult object that contains a partial view with the filtered result set .
modelId
string