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

TextInput as EditTrigger not adding first character

17 Answers 151 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ingólfur
Top achievements
Rank 1
Ingólfur asked on 13 Feb 2013, 11:38 AM
It seems that the first character entered is only handled as the EditTrigger but the actual character isn't input in the grid.

When I have a cell selected but not in edit mode I want to write 4567in it. In excel this would work. In radgrid the original 4 keypress would enter edit mode, then 567 would be entered into the cell. How can I make it so that the 4 is both handled as a EditTrigger as well as input?

17 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 13 Feb 2013, 12:18 PM
Hello,

We believe we have recently fixed such an issue. May I ask you to download the latest LIB and test with it. Please let me know about the result.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ingólfur
Top achievements
Rank 1
answered on 11 Apr 2013, 09:43 AM
I have 2013 Q1, would latest LIB be even newer then that?
0
Dimitrina
Telerik team
answered on 11 Apr 2013, 10:39 AM
Hello,

The fix should be included in 2013 Q1. Have you tested with it?

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ingólfur
Top achievements
Rank 1
answered on 15 Apr 2013, 10:48 AM
Yes and still not working as I hoped it would, I might have to mess with some properties.

Are you certain it should work as I'm thinking it should?

I wan't to be out of edit mode, type in 12000 and that goes into the box, instead of 1 being the trigger and only 2000 goes into the box.
0
Ingólfur
Top achievements
Rank 1
answered on 15 Apr 2013, 04:27 PM
Ok I found a codesample for EditTriggers on this site and it works fine. So evidently there is something different with my code.

What could it possibly be. Perhaps the fact I have varied types of columns in my grid, For example I've got GridViewMaskedTextBoxColumns as the main columns where I try to change the data and also ButtonColumns and/or GridVIewDataColumn for labels.

Could that interfere in any way?
0
Ingólfur
Top achievements
Rank 1
answered on 15 Apr 2013, 05:00 PM
Ok I think the problem is that EditTriggers do not work properly when using GridViewMaskedTextBoxColumn. Can you confirm that this is the problem?
0
Accepted
Dimitrina
Telerik team
answered on 16 Apr 2013, 01:49 PM
Hello,

I am not able to reproduce a problem with the regular GridViewDataColumn having a TextBox as their editor. With the GridViewMaskedTextBoxColumn the behavior is observed and it is due to the specifics of the RadMaskedTextBox editor. We have plans to obsolete it and that is why I would suggest you to define a regular column and set its CellEditTemplate to be one of our Masked Input controls.

You can check our online documentation here and the MaskedTextInput WPF Demo.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
David
Top achievements
Rank 1
answered on 08 May 2013, 01:00 PM
I'm using WPF Q1 2013 SP1 (still in trial) and have this problem.

The GridView has EditTriggers="Default"

Here's my column definition.
<telerik:GridViewDataColumn DataMemberBinding="{Binding RequestedQty}" 
                    Header="Req Qty" 
                    Width="75" TextAlignment="Right" 
                    HeaderTextAlignment="Right" 
                    DataFormatString="n" >
  <telerik:GridViewDataColumn.CellEditTemplate>
    <DataTemplate>
       <telerik:RadMaskedNumericInput 
               Value="{Binding RequestedQty, UpdateSourceTrigger=LostFocus}" 
               Mask="" FormatString="n" 
               HorizontalAlignment="Right" 
               HorizontalContentAlignment="Stretch" 
               InputBehavior="Replace" 
               SelectionOnFocus="SelectAll" 
               IsClearButtonVisible="False" 
               maskedInput:MaskedInputExtensions.Minimum="0" />
    </DataTemplate>
  </telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>

If a cell created using this column definition is focused but not in edit mode the first charachter entered puts it in edit mode as expected but that character is lost as stated by the OP.

Thanks,
Dave
0
Dimitrina
Telerik team
answered on 10 May 2013, 12:39 PM
Hello,

Thank you for the code snippet.
I were able to reproduce the issue. We are aware of the problem and we are currently working on resolving it. 

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Robert
Top achievements
Rank 1
answered on 31 May 2013, 05:17 PM
I have the same issue with a RadNumericUpDown in the CellEditTemplate.

Edit: Sorry, didn't notice this was the WPF forum, my issue is in Silverlight.
0
Yordanka
Telerik team
answered on 04 Jun 2013, 06:56 AM
Hi Robert,

The problem should be fixed with our latest internal build - version 2013.1.0527. Could you give it a try and let us know if you find any problems?

Regards,
Yordanka
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Thilo
Top achievements
Rank 1
Iron
answered on 09 Sep 2014, 08:44 PM
I have this Problem in the newest Version 2014.2.729.45.
Is there a solution ?
I Think it has to do with SelectionOnFocus="SelectAll", but this is the only Option for me that is usable to Enter a Number Value.

Thanks,
Thilo
0
Dimitrina
Telerik team
answered on 12 Sep 2014, 03:07 PM
Hello Thio,

I tested the code snippet previously shared. The result I observed is the the first character is actually entered, it is that the entire value is selected. Therefore, the next input clears the selected value.

It is not reproducible in case I change the SelectionOnFocus setting. I understand this is the only option usable for you, however, once you select all the text and you enter a new one, the old text will be lost. This would be the expected behavior.

Regards,
Dimitrina
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Anatoly
Top achievements
Rank 1
answered on 27 Mar 2015, 02:28 PM
Hello, Dimitrina.

I have the same problem with first character when I use UserControl as column editor with RadComboBox and RadDatePicker controls in it.
Here is the content of UserControl XAML:
<UserControl x:Class="Example1.SelectDateComboboxControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             mc:Ignorable="d"
             d:DesignWidth="300">


    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="25"/>
        </Grid.ColumnDefinitions>
        <telerik:RadComboBox x:Name="ComboBox" Grid.Column="0" Grid.ColumnSpan="2"
                                             IsTextSearchEnabled="True"
                                             IsEditable="True"
                                             TabIndex="0"
                                             TextSearchMode="StartsWith"
                                             SelectAllTextEvent="None"/>
        <telerik:RadDatePicker x:Name="Calendar" Grid.Column="1" DateSelectionMode="Day" Focusable="False" TabIndex="1"     IsTabStop="False"/>
    </Grid>
</UserControl>

I tried to set keyboard focus by calling Keyboard.Focus(ComboBox)in Loaded elent of this UserControl - no luck. ComboBox got focus but it is empty.
Here is column method for creating this UserControl editor:

        public override FrameworkElement CreateCellEditElement(GridViewCell cell, object dataItem)
        {
            var cellEditElement = new SelectDateComboboxControl();

            BindingTarget = SelectDateComboboxControl.ValueProperty;

            var valueBinding = CreateValueBinding();
            cellEditElement.SetBinding(this.BindingTarget, valueBinding);
            return cellEditElement;
        }

        protected virtual Binding CreateValueBinding()
        {
            var valueBinding = new Binding
                               {
                                   Mode = BindingMode.TwoWay,
                                   NotifyOnValidationError = true,
                                   ValidatesOnExceptions = true,
                                   UpdateSourceTrigger = UpdateSourceTrigger.Explicit,
                                   Converter = GetDisplayValueConverter(),
                                   ConverterParameter = ValueType,
                                   Path = new PropertyPath(DataMemberBinding.Path.Path)
                               };

            return valueBinding;
        }

Here is the part of UserControl:

    public partial class SelectDateComboboxControl : UserControl
    {
        public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
            "Value", typeof (string), typeof (SelectDateComboboxControl), new PropertyMetadata(default(string)));

        public string Value
        {
            get { return (string) GetValue(ValueProperty); }
            set
            {
                SetValue(ValueProperty, value);
                ComboBox.Text = value;
            }
        }
       ...

How RadGridView determine to what control in column editor to pass entered character?


0
Dimitrina
Telerik team
answered on 30 Mar 2015, 12:49 PM
Hi Anatoly,

As it turns out when you have redefined the CellEditTemplate of GridViewDataColumn, then the text input over the cell prior going into edit mode will not be directly propagated to the RadComboBox element you defined as an editing element. 

You can try the following work around:
private void pilotsGrid_PreparingCellForEdit(object sender, GridViewPreparingCellForEditEventArgs e)
{
     TextCompositionEventArgs textCompositionEventArgs = e.EditingEventArgs as TextCompositionEventArgs;
     if (textCompositionEventArgs != null)
     {
         RadComboBox comboBox = e.EditingElement as RadComboBox;
         if (comboBox != null)
         {
             comboBox.Text = textCompositionEventArgs.Text;
         }
     }
}

Let me know how it works for you.


Regards,
Dimitrina
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Anatoly
Top achievements
Rank 1
answered on 31 Mar 2015, 07:16 AM
Hi, Dimitrina.
Your workaround works fine, thank you. I just wondering why I cannnot get this entered value in some overrided method of my custom column class, for example in CreateCellEditElement where I create my custom editor control.
0
Dimitrina
Telerik team
answered on 01 Apr 2015, 12:57 PM
Hi,

This logic is incorporated in the design of the columns and as it turns out I cannot suggest you on how to access this exact information on CreateCellEditElement instead.

Regards,
Dimitrina
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
GridView
Asked by
Ingólfur
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Ingólfur
Top achievements
Rank 1
David
Top achievements
Rank 1
Robert
Top achievements
Rank 1
Yordanka
Telerik team
Thilo
Top achievements
Rank 1
Iron
Anatoly
Top achievements
Rank 1
Share this question
or