Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 896 Bytes

Using_list_filter.md

File metadata and controls

28 lines (20 loc) · 896 Bytes

GridMvc for ASP.NET Core MVC

Using a list filter

Index

There can be columns where their values can only be selected from a short list. You can use an special filter based on a list for those columns. It looks like:

In order to use a list filter you have to create a list of SelectItem objects in first place:

    var shipperList = _shippersRepository.GetAll()
        .Select(s => new SelectItem(s.ShipperID.ToString(), r.ShipperID.ToString() + " - " + r.CompanyName))
        .ToList();

Then you have to add the column using the SetListFilter method of the GridColumn object:

    c.Add(o => o.ShipVia)
        .RenderValueAs(o => o.Shipper.CompanyName)
        .SetListFilter(shipperList);

<- Filtering | Creating custom filter widget ->