This is a migrated thread and some comments may be shown as answers.

DataGrid not respecting the minimum I set

9 Answers 84 Views
DataGrid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jeremiah
Top achievements
Rank 1
Jeremiah asked on 19 Nov 2017, 10:22 PM

I'm having problems with the DataGrid not respecting the minimum I set - I want it to be able to accept negative values, but it simply will not.

I've put some code below, and here is a link to a sample project that has the problem.

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
 
    <grid:RadDataGrid x:Name="grid" DataContext="{StaticResource ViewModel}" ItemsSource="{Binding Items}" UserEditMode="External" UserGroupMode="Disabled" AutoGenerateColumns="False">
        <grid:RadDataGrid.Columns>
            <grid:DataGridTextColumn PropertyName="Country" Header="Country"/>
            <grid:DataGridTextColumn PropertyName="Capital" Header="Capital"/>
            <grid:DataGridNumericalColumn PropertyName="Amount" Header="Amount">
                <grid:DataGridNumericalColumn.CellEditorStyle>
                    <Style TargetType="input:RadNumericBox">
                        <Setter Property="Minimum" Value="-1000"/>
                        <Setter Property="Maximum" Value="1000"/>
                        <Setter Property="ValueFormat" Value="{}{0,0:C2}"/>
                    </Style>
                </grid:DataGridNumericalColumn.CellEditorStyle>
            </grid:DataGridNumericalColumn>
        </grid:RadDataGrid.Columns>
 
                <grid:RadDataGrid.Commands>
            <commands:DataGridUserCommand Id="CommitEdit"
                                          Command="{Binding Source={StaticResource ViewModel}, Path=MyCommand}" />
        </grid:RadDataGrid.Commands>
    </grid:RadDataGrid>
 
</Grid>

9 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 22 Nov 2017, 04:07 PM
Hi, Jeremiah,

Thank you for providing the sample. We are currently investigating the behavior. I will update the thread once we have more information on the matter. 

Have a great rest of the week.

Regards,
Stefan Nenchev
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Stefan Nenchev
Telerik team
answered on 27 Nov 2017, 02:08 PM
Hello, Jeremiah,

I have attached a sample project which shows how to achieve the desired behavior. Please have a look at the custom command which is executed when starting to edit the DataGrid.

Regards,
Stefan Nenchev
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jeremiah
Top achievements
Rank 1
answered on 28 Nov 2017, 04:19 AM

Hi Stefan,

Is there supposed to be an CustomExternalEditor.cs file in that project?

Regards,

Jeremiah

0
Stefan Nenchev
Telerik team
answered on 28 Nov 2017, 10:44 AM
Hello, Jeremiah,

I started testing another approach but changed it and decided to delete this file. You can disregard it and check the CustomBeginEditCommand implementation.

Regards,
Stefan Nenchev
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jeremiah
Top achievements
Rank 1
answered on 29 Nov 2017, 01:39 AM

The method you are using works, but inconsistently. Sometimes it allows for negative values, but other times it does not. I suspect this is because of the asynchronous nature of the code you are using?

I doubt it is of much consequence, but I should note that I have to use the x86 configuration, as I do not have the emulators installed to run the code as ARM.

0
Jeremiah
Top achievements
Rank 1
answered on 02 Dec 2017, 05:26 PM
Since it is open source, I will look at the code on GitHub. I will post back when I find a solution.
0
Stefan Nenchev
Telerik team
answered on 04 Dec 2017, 08:36 AM
Hello, Jeremiah,

Indeed, the approach I have provided is just a workaround and might not be ideal as we have not fully tested it. You can create an issue in the GitHub repository regarding the behavior and if you manage to identify the problematic part of the source code and provide a fix - to create a pull request. Any additional information will be appreciated as well. Thank you for the efforts!

Have a great week. 

Regards,
Stefan Nenchev
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jeremiah
Top achievements
Rank 1
answered on 08 Dec 2017, 01:33 AM

I was unable to find a solution to my own project, so I ended up modifying the library directly. The following file has the default minimum and maximum values:

UI-For-UWP/Controls/Primitives/Primitives.UWP/RangeBaseControls/RangeControlBase.cs

What I did was to set the default values to Double.MinValue and Double.MaxValue.

I don't see this as a great solution for all projects that use the libraries (it might affect other controls like sliders), but for the purpose of my own project it will suffice.

Ideally I would find the root cause of the setter properties not being respected, but I am not experienced enough in debugging Setters in XAML, or in debugging third party libraries.

0
Stefan Nenchev
Telerik team
answered on 12 Dec 2017, 01:13 PM
Hello, Jeremiah,

Thank you for the additional information provided. I have added some points to your account as the approach might be useful for other users that come across the behavior. In the meantime, I have also logged the behavior as a bug in our internal system and you can track its progress on the following link from our Ideas & Feedback portal - DataGrid: NumericEditor not respecting the minimum value set. I suggest you subscribe to the item in order to receive automatic notifications.

Have a great rest of the week.

Regards,
Stefan Nenchev
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DataGrid
Asked by
Jeremiah
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Jeremiah
Top achievements
Rank 1
Share this question
or