DataGrid FilterTemplate not working #31

Closed
opened 2026-01-29 17:30:24 +00:00 by claunia · 2 comments
Owner

Originally created by @devlife on GitHub (Feb 12, 2021).

Describe the bug
I added a FilterTemplate with a dropdown to a column in a DataGrid for a string property but the filter is never applied.

To Reproduce

  1. Add RadzenGrid which allows filtering
  2. Add a filter template with a drop down to one of the columns with a string value
  3. Run the app and attempt to filter using the drop down
  4. Notice that no filtering has been applied.

The zip file contains an mp4 which shows the filter not working.
filter not working.zip

Here is my code:

<RadzenGrid 
            AllowFiltering="true"
            FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive"
            FilterMode="FilterMode.Advanced"
            AllowColumnResize="true"
            Count="@Count"
            Data="@Campaigns"
            LoadData="@LoadData"
            AllowSorting="true"
            AllowPaging="true"
            PageSize="100"
            TItem="CampaignListViewModel"
            ColumnWidth="200px">

    <Columns>
        <RadzenGridColumn TItem="CampaignListViewModel">
            <Template>
                <RadzenButton Icon="edit" Size="ButtonSize.Small">
                </RadzenButton>
            </Template>
        </RadzenGridColumn>
        <RadzenGridColumn TItem="CampaignListViewModel" Property="CampaignName" Title="Campaign Name" />
        <RadzenGridColumn TItem="CampaignListViewModel" Property="ClientName" Title="Client Name" />
        <RadzenGridColumn TItem="CampaignListViewModel" Property="Status" Title="Status">
            <FilterTemplate>
                <RadzenDropDown @bind-Value="@SelectedStatusFilter" TextProperty="Key" ValueProperty="Value" Style="width:100%"
                                Data="@StatusFilters.Select(kv => new { Key = kv.Key, Value = kv.Value })" />
            </FilterTemplate>
        </RadzenGridColumn>
        <RadzenGridColumn TItem="CampaignListViewModel" Property="ResearchStatus" Title="Research Status" />
        <RadzenGridColumn TItem="CampaignListViewModel" Property="ResponseGoal" Title="Response Goal" />
    </Columns>
</RadzenGrid>
public string SelectedStatusFilter { get; set; }

public IEnumerable<KeyValuePair<string, string>> StatusFilters => new[]
{
    new KeyValuePair<string, string>("Active", "Active"),
    new KeyValuePair<string, string>("Inactive", "Inactive")
};

Expected behavior
I'd expect the filter to be applied

Screenshots
image
image
image

Desktop (please complete the following information):

  • OS: Window 10 Pro
  • Browser Edge, Chrome
  • Version Edge: 88.0.705.63; Chrome: 88.0.4324.150

Additional context
Add any other context about the problem here.

Originally created by @devlife on GitHub (Feb 12, 2021). <!-- IMPORTANT: Read this first!!! 1. If you own a Radzen Professional or Еnterprise subscription you can report your issue or ask us a question via email at info@radzen.com. Radzen staff will reply within 24 hours (Professional) or 16 hours (Enterprise) 2. The Radzen staff guarantees a response to issues in this repo only to paid subscribers. 3. If you have a HOW TO question start a new forum thread in the Radzen Community forum: https://forum.radzen.com. Radzen staff will close issues that are HOWTO questions. 4. Please adhere to the issue template. Specify all the steps required to reproduce the issue or link a project which reproduces it easily (without requiring extra steps such as restoring a database). --> **Describe the bug** I added a FilterTemplate with a dropdown to a column in a DataGrid for a string property but the filter is never applied. **To Reproduce** 1. Add RadzenGrid which allows filtering 2. Add a filter template with a drop down to one of the columns with a string value 3. Run the app and attempt to filter using the drop down 4. Notice that no filtering has been applied. The zip file contains an mp4 which shows the filter not working. [filter not working.zip](https://github.com/radzenhq/radzen-blazor/files/5972761/filter.not.working.zip) Here is my code: ``` <RadzenGrid AllowFiltering="true" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" FilterMode="FilterMode.Advanced" AllowColumnResize="true" Count="@Count" Data="@Campaigns" LoadData="@LoadData" AllowSorting="true" AllowPaging="true" PageSize="100" TItem="CampaignListViewModel" ColumnWidth="200px"> <Columns> <RadzenGridColumn TItem="CampaignListViewModel"> <Template> <RadzenButton Icon="edit" Size="ButtonSize.Small"> </RadzenButton> </Template> </RadzenGridColumn> <RadzenGridColumn TItem="CampaignListViewModel" Property="CampaignName" Title="Campaign Name" /> <RadzenGridColumn TItem="CampaignListViewModel" Property="ClientName" Title="Client Name" /> <RadzenGridColumn TItem="CampaignListViewModel" Property="Status" Title="Status"> <FilterTemplate> <RadzenDropDown @bind-Value="@SelectedStatusFilter" TextProperty="Key" ValueProperty="Value" Style="width:100%" Data="@StatusFilters.Select(kv => new { Key = kv.Key, Value = kv.Value })" /> </FilterTemplate> </RadzenGridColumn> <RadzenGridColumn TItem="CampaignListViewModel" Property="ResearchStatus" Title="Research Status" /> <RadzenGridColumn TItem="CampaignListViewModel" Property="ResponseGoal" Title="Response Goal" /> </Columns> </RadzenGrid> ``` ``` public string SelectedStatusFilter { get; set; } public IEnumerable<KeyValuePair<string, string>> StatusFilters => new[] { new KeyValuePair<string, string>("Active", "Active"), new KeyValuePair<string, string>("Inactive", "Inactive") }; ``` **Expected behavior** I'd expect the filter to be applied **Screenshots** ![image](https://user-images.githubusercontent.com/237369/107789055-1e9dbd80-6d1f-11eb-8152-ce0d4262a4b6.png) ![image](https://user-images.githubusercontent.com/237369/107789269-615f9580-6d1f-11eb-8e24-1462e3f04c64.png) ![image](https://user-images.githubusercontent.com/237369/107789204-4ee55c00-6d1f-11eb-9a6c-100c13337472.png) **Desktop (please complete the following information):** - OS: Window 10 Pro - Browser Edge, Chrome - Version Edge: 88.0.705.63; Chrome: 88.0.4324.150 **Additional context** Add any other context about the problem here.
Author
Owner

@akorchev commented on GitHub (Feb 12, 2021):

Your code does not implement any filtering (or the code isn't included). Check our FilterTemplate demo for a reference.

@akorchev commented on GitHub (Feb 12, 2021): Your code does not implement any filtering (or the code isn't included). Check our [FilterTemplate](https://github.com/radzenhq/radzen-blazor/blob/master/RadzenBlazorDemos/Pages/DataGridColumnFilterTemplatePage.razor) demo for a reference.
Author
Owner

@devlife commented on GitHub (Feb 12, 2021):

Ah! I missed that piece. Thank you.

@devlife commented on GitHub (Feb 12, 2021): Ah! I missed that piece. Thank you.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#31