JimboJones
JimboJones

Reputation: 131

Mudblazor MudDataGrid - Make Filter case insensitive

I have been learning Blazor along with using MudBlazor controls. I really like the MudDataGrid and will be using it in an upcoming project. The one thing the business wants is to be able to search/filter within a grid. The filtering seems to be working great and I have it setup and working

    <MudDataGrid Items="@links.Result" Dense="true" Elevation="10" Filterable="true" FilterMode="DataGridFilterMode.ColumnFilterMenu">
    <Columns>
        @*<Column T="LinkForGrid" Field="GroupTitle" Title="Title" /> The field value is necessary if using sorting.. sorting is on by default  *@
        <Column T="LinkForGrid" Title="Product" Field="GroupID" Filterable="false">
            <CellTemplate>@(context.Item.GroupID)</CellTemplate>
        </Column>
        <Column T="LinkForGrid" Title="Link Title" Field="LinkText">
            <CellTemplate>
                <MudLink Href="@context.Item.LinkURL" target="@(context.Item.OpenInNewWindow ? "_blank" : "_self")">@context.Item.LinkText</MudLink>
            </CellTemplate>
        </Column>
        @*            <Column T="LinkForGrid" Title="Product" Field="GroupTitle"></Column>*@
        <Column T="LinkForGrid" Title="Effective Date" Field="EffectiveDate" Filterable="false">
            <CellTemplate>@context.Item.EffectiveDate.ToShortDateString()</CellTemplate>
        </Column>

    </Columns>
</MudDataGrid>
The issue I am having is that when you use filtering on a string column as I am, it is case sensitive and I would like it to be case-insensitive. Does anyone know a way to do it with or without custom code? I have looked at the documentation and Googled but have not found anything yet. I know MudBlazor controls are "new" and the grid is a work in progress, but this seems to me like a property should be available to change the search type. If anyone has any suggestions, I'd appreciate it.

Thanks, Jim

Upvotes: 0

Views: 2435

Answers (2)

Corn&#233; Oosthuizen
Corn&#233; Oosthuizen

Reputation: 11

I see they added the option FilterCaseSensitivity="DataGridFilterCaseSensitivity.CaseInsensitive" to the MudDataGrid.

Example:

<MudDataGrid T="sampleType" Items="_sampleList" ReadOnly="true" SortMode="SortMode.Multiple" Filterable="true" FilterMode="DataGridFilterMode.ColumnFilterMenu"
                 FilterCaseSensitivity="DataGridFilterCaseSensitivity.CaseInsensitive" Bordered="true" Striped="true" Hover="true" Dense="true" Hideable="true">

Upvotes: 1

Dorian
Dorian

Reputation: 983

i searched also some days ago but didnt found

you have to do this as in their example https://dev.mudblazor.com/components/datagrid

 <MudDataGrid T="Element" MultiSelection="true" Items="@Elements" SortMode="SortMode.Multiple" Filterable="true" QuickFilter="@_quickFilter"
Hideable="true" RowClick="@RowClicked" SelectedItemsChanged="@SelectedItemsChanged">

and in

  @code {
  private Func<Element, bool> _quickFilter => x =>
  {
    if (x.Sign.Contains(_searchString, StringComparison.OrdinalIgnoreCase))
        return true;
   }

Upvotes: 1

Related Questions