How to set properties in the filter control for numerical column in RadDataGrid?

1 Answer 39 Views
DataGrid
Pavel Krebs
Top achievements
Rank 1
Pavel Krebs asked on 13 Feb 2024, 09:02 AM

I have simple datagrid with numerical columns and when I switch on column filter dialog it is impossible to enter values over 100 or below 0. It looks like that RadNumericBox is limited to range <0,100>. I am able to disable distinct values but nothing else.

For example:


    <telerikgrid:RadDataGrid x:Name="MeasuredProfilesDataGrid" ItemsSource="{x:Bind ViewModel.Points}" AutoGenerateColumns="False" SelectionMode="Extended" SelectionUnit="Row" UserGroupMode="Disabled" UserEditMode="Inline">

        <telerikgrid:RadDataGrid.Columns>
            <telerikgrid:DataGridNumericalColumn PropertyName="StationingUserValue" Header="{x:Bind HeaderViewModel.StationingHeader}" CellContentFormat="{x:Bind HeaderViewModel.StationingFormatString}" ShowDistinctValuesFilter="False"/>
            <telerikgrid:DataGridNumericalColumn PropertyName="OffsetXUserValue" Header="{x:Bind HeaderViewModel.OffsetXHeader}" CellContentFormat="{x:Bind HeaderViewModel.LocalDistanceFormatString}" ShowDistinctValuesFilter="False"/>
            <telerikgrid:DataGridNumericalColumn PropertyName="OffsetYUserValue" Header="{x:Bind HeaderViewModel.OffsetYHeader}" CellContentFormat="{x:Bind HeaderViewModel.LocalDistanceFormatString}" ShowDistinctValuesFilter="False"/>
            <telerikgrid:DataGridNumericalColumn PropertyName="EastingUserValue" Header="{x:Bind HeaderViewModel.EastingHeader}" CellContentFormat="{x:Bind HeaderViewModel.ENHFormatString}" ShowDistinctValuesFilter="False"/>
            <telerikgrid:DataGridNumericalColumn PropertyName="NorthingUserValue" Header="{x:Bind HeaderViewModel.NorthingHeader}" CellContentFormat="{x:Bind HeaderViewModel.ENHFormatString}" ShowDistinctValuesFilter="False"/>
            <telerikgrid:DataGridNumericalColumn PropertyName="HeightUserValue" Header="{x:Bind HeaderViewModel.HeightHeader}" CellContentFormat="{x:Bind HeaderViewModel.ENHFormatString}" ShowDistinctValuesFilter="False"/>
        </telerikgrid:RadDataGrid.Columns>
    </telerikgrid:RadDataGrid>

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 15 Feb 2024, 03:36 PM

Hello Pavel,

It turns out that this is a bug in the RadDataGrid component. The RadNumericBox in the filtering control is using the default range which is between 0 and 100. You can find this logged in our feedback portal. I also updated your Telerik points.

To work this around, you can extract the ControlTemplate of DataGridNumericalFilterControl and modify it in order the change the Minimum and Maximum settings of the RadNumericBox element.

<?xml version="1.0" encoding="utf-8"?>
<Application
    x:Class="App3.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App3" xmlns:telerikDataGrid="using:Telerik.UI.Xaml.Controls.Grid.Primitives" xmlns:telerikInput="using:Telerik.UI.Xaml.Controls.Input">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
                <ResourceDictionary Source="ms-appx:///Telerik.WinUI.Controls/Themes/Generic.xaml"/>
                <!-- Other merged dictionaries here -->
            </ResourceDictionary.MergedDictionaries>

            <Style TargetType="telerikDataGrid:DataGridNumericalFilterControl">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="telerikDataGrid:DataGridNumericalFilterControl">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <ComboBox x:Name="PART_OperatorCombo" 
                                          HorizontalAlignment="Stretch"
                                          ItemsSource="{Binding OperatorsList}"
                                          SelectedItem="{Binding FilterDescriptor.Operator, Mode=TwoWay, Converter={StaticResource FilterOperatorConverter}}" 
                                          DisplayMemberPath="DisplayText">
                                </ComboBox>
                                <telerikInput:RadNumericBox x:Name="PART_ValueBox"
                                                            Minimum="NaN"
                                                            Maximum="NaN"
                                              HorizontalAlignment="Stretch"
                                              Value="{Binding FilterDescriptor.Value, Mode=TwoWay}"
                                              Grid.Row="1" Margin="0 10 0 0"/>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <!-- Other app resources here -->
        </ResourceDictionary>
    </Application.Resources>
</Application>

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
DataGrid
Asked by
Pavel Krebs
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or