Edit Numeric Values

5 posts, 0 answers
  1. Thilo
    Thilo avatar
    26 posts
    Member since:
    Feb 2011

    Posted 30 Jan 2014 Link to this post

    Hello !
    I want to Edit Numeric Values with 2 digits in an GridView.

    My First Solution:
    Using an GridViewDataColumn and set the CellEditTemplate to a
    RadMaskedNumericInput like this (SelectionOnFocus="SelectAll" (Important!))
    <telerik:GridViewDataColumn Header="Listenpreis" Width="80" TextAlignment="Right" HeaderTextAlignment="Right"
                                DataMemberBinding="{Binding Path=Listenpreis}" DataFormatString="F2">
      <telerik:GridViewDataColumn.CellEditTemplate>
         <DataTemplate>
            <telerik:RadMaskedNumericInput Margin="0" SelectionOnFocus="SelectAll" HorizontalAlignment="Stretch"
                   Value="{Binding Path=Listenpreis, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}"
                   SpinMode="None"
                   FormatString="n2"/>
         </DataTemplate>
      </telerik:GridViewDataColumn.CellEditTemplate>
    </telerik:GridViewDataColumn>
    This works well for Editing, but the Enter Key doesn't work as expected to go to the next Row in the same Column.
    I can Only change the Column with the Tab Key.

    My Second Solution:
    Using an GridViewMaskedInputColumn like this:
    <telerik:GridViewMaskedInputColumn Header="Listenpreis3" Width="80" TextAlignment="Right" HeaderTextAlignment="Right"
                                       MaskType="Numeric"
                                       DataMemberBinding="{Binding Path=Listenpreis}" DataFormatString="{} {0:N2}"  />

    But here i'am missing the 2 Digits Mask on Editing and "SelectAll" on Enter the Cell.

    How can i get this working as expected ?
  2. Thilo
    Thilo avatar
    26 posts
    Member since:
    Feb 2011

    Posted 30 Jan 2014 in reply to Thilo Link to this post

    OK, my Working Solution is to define the EditorStyle like this:
    <telerik:GridViewMaskedInputColumn x:Name="listenpreisColumn" Header="Listenpreis" Width="90" TextAlignment="Right" HeaderTextAlignment="Right"
                                       MaskType="Numeric"
                                       DataMemberBinding="{Binding Path=Listenpreis}" DataFormatString="{} {0:N2}" >
        <telerik:GridViewMaskedInputColumn.EditorStyle>
            <Style TargetType="telerik:RadMaskedNumericInput">
                <Setter Property="SelectionOnFocus" Value="SelectAll" />
                <Setter Property="FormatString" Value="N2" />
                <Setter Property="SpinMode" Value="None" />
            </Style>
        </telerik:GridViewMaskedInputColumn.EditorStyle>
    </telerik:GridViewMaskedInputColumn>
  3. Peter
    Peter avatar
    16 posts
    Member since:
    Nov 2018

    Posted 15 Feb in reply to Thilo Link to this post

    Hello,

    I have a similiar problem. I cannot confirm the input with the return/enter key. The use of EditorStyle-Property is not an option, because I am using the EditCellTemplateSelector for switching between hex and dec input.

    Here is my GridViewColumn:

    <telerik:GridViewDataColumn Header="{lex:Loc IDS_LIST_VALUES_COLUMN_VALUE}" Width="100"
                                SortMemberPath="Value">
     
        <telerik:GridViewDataColumn.CellTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding ValueString}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
            </DataTemplate>
        </telerik:GridViewDataColumn.CellTemplate>
     
        <telerik:GridViewDataColumn.CellEditTemplateSelector>
            <utils:HexDecEditCellTemplateSelector>
                <utils:HexDecEditCellTemplateSelector.cellTemplateHexEdit>
                    <DataTemplate>
                        <telerik:RadMaskedTextInput Style="{StaticResource RadMaskedNumericInputHexStyle}"
                                                    Mask=">X8"
                                                    Value="{Binding ValueEditString, ValidatesOnDataErrors=True}"/>
                    </DataTemplate>
                </utils:HexDecEditCellTemplateSelector.cellTemplateHexEdit>
                <utils:HexDecEditCellTemplateSelector.cellTemplateDecEdit>
                    <DataTemplate>
                        <!-- TODO: Input confirmation with Enter does not work here -->
                        <telerik:RadMaskedNumericInput Style="{StaticResource RadMaskedNumericInputDezStyle}"
                                                       Value="{Binding ValueEditString, ValidatesOnDataErrors=True}"/>
                    </DataTemplate>
                </utils:HexDecEditCellTemplateSelector.cellTemplateDecEdit>
            </utils:HexDecEditCellTemplateSelector>
        </telerik:GridViewDataColumn.CellEditTemplateSelector>
         
    </telerik:GridViewDataColumn>

     

    Can you help me with that plz?

     

    regards,

    Tobias

  4. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    1255 posts

    Posted 18 Feb Link to this post

    Hello Peter,

    Thank you for the provided code snippet.

    One approach I can suggest with your particular setup would be to set the AcceptsReturn property of the two masked input controls to False.

                        <telerik:GridViewDataColumn.CellEditTemplateSelector>
                            <telerik:GridViewDataColumn.CellEditTemplateSelector>
                                <utils:HexDecEditCellTemplateSelector>
                                    <utils:HexDecEditCellTemplateSelector.cellTemplateHexEdit>
                                        <DataTemplate>
                                            <telerik:RadMaskedTextInput Style="{StaticResource RadMaskedNumericInputHexStyle}"
                                                    Mask=">X8" 
                                                    AcceptsReturn="False"
                                                    Value="{Binding ValueEditString, ValidatesOnDataErrors=True}"/>
                                        </DataTemplate>
                                    </utils:HexDecEditCellTemplateSelector.cellTemplateHexEdit>
                                    <utils:HexDecEditCellTemplateSelector.cellTemplateDecEdit>
                                        <DataTemplate>
                                            <!-- TODO: Input confirmation with Enter does not work here -->
                                            <telerik:RadMaskedNumericInput Style="{StaticResource RadMaskedNumericInputDezStyle}"
                                                                           AcceptsReturn="False"
                                                                           Value="{Binding ValueEditString, ValidatesOnDataErrors=True}"/>
                                        </DataTemplate>
                                    </utils:HexDecEditCellTemplateSelector.cellTemplateDecEdit>
                                </utils:HexDecEditCellTemplateSelector>
                            </telerik:GridViewDataColumn.CellEditTemplateSelector>
                        </telerik:GridViewDataColumn.CellEditTemplateSelector>

    Could you please give this a try and let me know if this approach works for you? I will be awaiting your reply.

    Regards,
    Dilyan Traykov
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

  5. Peter
    Peter avatar
    16 posts
    Member since:
    Nov 2018

    Posted 22 Feb in reply to Dilyan Traykov Link to this post

    That does the trick! Tanks!
Back to Top