# Get All Grid Filters Recursively and Modify Them on the Server

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Telerik UI for ASP.NET MVC Grid</td>
 </tr>
 <tr>
  <td>Product version</td>
  <td>2025.1.227</td>
 </tr>
</table>

## Description

How can I access all requested filters recursively and modify them on the server?

## Solution

You can achieve this requirement using the following implementation:

1. Configure the Grid for Ajax data binding.

   ```Razor HtmlHelper
   @(Html.Kendo().Grid<Telerik.Examples.Mvc.Areas.GridModifyFiltersOnTheServer.Models.Order>()
       .Name("grid")
       .Filterable()
       .DataSource(dataSource => dataSource
           .Ajax()
           .Read(read => read.Action("Read", "Home"))
           ... // Additional options.
       )
       ... // Additional configuration.
   )
   ```

2. Retrieve the requested filters through the `DataSourceRequest` object and adjust filter criteria on the server side before processing the request.

   ```C#
   public ActionResult Read([DataSourceRequest] DataSourceRequest request)
   {
       ModifyFilters(request.Filters);

       return Json(OrderRepository.GetAll().ToDataSourceResult(request));
   }

   private void ModifyFilters(IEnumerable<IFilterDescriptor> filters)
   {
       if (filters.Any())
       {
           foreach (var filter in filters)
           {
               var descriptor = filter as FilterDescriptor;
               if (descriptor != null && descriptor.Member == "OrderDate")
               {
                   descriptor.Member = "OrderDate.Date";
               }
               else if (filter is CompositeFilterDescriptor)
               {
                   ModifyFilters(((CompositeFilterDescriptor)filter).FilterDescriptors);
               }
           }
       }
   }
   ```

To see the complete example, refer to the [project on how to access all Grid filters and modify them on the server based on your requirements](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/Telerik.Examples.Mvc/Telerik.Examples.Mvc/Areas/GridModifyFiltersOnTheServer).

## More ASP.NET MVC Grid Resources

* [ASP.NET MVC Grid Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/grid/overview)
* [ASP.NET MVC Grid Demos](https://demos.telerik.com/aspnet-mvc/grid/index)
* [ASP.NET MVC Grid Product Page](https://www.telerik.com/aspnet-mvc/grid)
* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)
* [Telerik UI for ASP.NET MVC Forums](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [Client-Side API Reference of the Grid for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/grid)
* [Server-Side API Reference of the Grid for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/grid)
* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
