Telerik RadGridView – Custom Filtering Controls for a list of viewmodels

  Kiến thức lập trình

I need help with the design and how to implement a custom filter. If someone can help me with a small example or with the basic structure, I have been reading the “Custom Filtering Controls” documentation (https://docs.telerik.com/devtools/wpf/controls/radgridview/filtering/custom-filtering-controls) but I am having trouble implementing it for this case.

Currently I have a RadGridView, which shows a list of orders. One of the columns shows a list of icons:

public required List<IMvvmViewModel?> DesignStatusViewModels { get; set; }

Column:

<telerik:GridViewDataColumn IsReadOnly="True" HeaderCellStyle="{StaticResource DesignStatusCellStyle}">
    <telerik:GridViewDataColumn.Header>
        <TextBlock  
            Text="Design Status" 
            MinWidth="100"
            Width="Auto"
            TextAlignment="Center">
        </TextBlock>
    </telerik:GridViewDataColumn.Header>                    
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <ItemsControl ItemsSource="{Binding DesignStatusViewModels}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel 
                            Orientation="Horizontal"
                            HorizontalAlignment="Right"
                            TextElement.FontSize="12"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <ContentPresenter 
                            Grid.Row="0"
                            Content="{Binding }"
                            VerticalAlignment="Center"
                            ContentTemplateSelector="{StaticResource DesignStatusContentTemplateSelector}" 
                            Margin="2,0,2,0"/>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

Each IMvvmViewModel has a bool, and a template, the template is responsible for showing the activated or not activated icon for each case, for example:

[DesignStatusTemplates(Template = typeof(DesignStatusRushOrderTemplate))]
publicpartialclassDesignStatusRushOrderViewModel : IMvvmViewModel
{
  publicbool IsRush { get; set;}
}
[DesignStatusTemplates(Template = typeof(DesignStatusExternalOrderTemplate))]
publicpartialclassDesignStatusExternalOrderViewModel : IMvvmViewModel
{
publicbool IsExternal { get; set;}
}

What I need is to make a custom filter for this column, which can filter with a checkbox or whatever is easier, for example all orders that have DesignStatusRushOrderViewModel -> IsRush == true.

Thank you very much! Juan

Make a custom filter

New contributor

Juanpabiker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT