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

AutoSelect TextInput EditTrigger

12 Answers 179 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
MiddleTommy
Top achievements
Rank 1
MiddleTommy asked on 25 Oct 2010, 03:45 PM
I am seeing a conflict in the TextInput EdditTrigger and an AutoSelectTextbox. I have the Eddit triggers set to CurrentCellClick and TextInput. I also have an auto select textbox as the editor that selects all the text when the cell is selected. This works good for the CurrentCellClick but not for the TextInput.
I am guessing that you are setting the value of the cell/property and then entering edit mode. As with the Autocomplete Textbox the character typed to enter edit mode is selected so any other characters entered overwrite the first character pressed.

I could scrap the Auto complete text box as an editor but then when users Tab from cell to cell in edit mode the contents will not be selected.

12 Answers, 1 is accepted

Sort by
0
Accepted
Nedyalko Nikolov
Telerik team
answered on 26 Oct 2010, 11:33 AM
Hello MiddleTommy,

I think that you do not need any special AutoSelect(Complete)TextBox controls for editors, since that you are describing the RadGridView's default editing + TAB navigation behavior. Let me clarify a little bit. When TAB key is pressed and current cell is in edit mode then RadGridView moves focus to the next editable cell's editing element. If this element is a custom control set via CellEditTemplate RadGridView sets focus to the first control which can take focus and if this control is textbox selects all text of it.
Could you please try your scenario with default columns and let me know about the result?

Best wishes,
Nedyalko Nikolov
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Brian Sayatovic
Top achievements
Rank 1
answered on 26 Mar 2013, 08:44 PM
The information in your answer is the first I've heard of this: "If this element is a custom control set via CellEditTemplate RadGridView sets focus to the first control which can take focus and if this control is textbox selects all text of it."

Is that documented anywhere else?

I'm experiencing a problem that when a cell that is focused, but not in edit mode, and the user types a single key (e.g. "2"), the cell enters edit mode, the existing content is replaced by "2" and the entire TextBox's contents are selected.  So then they try to type their second character, "3" and the 3 replaces the 2 instead of appending to it.

I've been struggling to find out why this is happening when I stumbled upon this thread suggesting the Telerik controls might purposefully be doing this.
0
Brian Sayatovic
Top achievements
Rank 1
answered on 27 Mar 2013, 01:09 PM
BTW, the GridView editing demo seems to exhibit this select-on-first-keypress behavior in the date column, but not in the name column.  What's the difference?

http://demos.telerik.com/silverlight/#GridView/CellEditTemplate
0
Nedyalko Nikolov
Telerik team
answered on 29 Mar 2013, 02:47 PM
Hi,

Thank you for reporting this issue. The difference is in the editor. "Name" column is edited via TextBox, and "Date" column by RadDateTimePicker. We will fix this with the upcoming service pack.

I've updated your Telerik points accordingly.

Kind regards,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Brian Sayatovic
Top achievements
Rank 1
answered on 29 Mar 2013, 03:10 PM
Thank you for the prompt attention. If I may, can you please clarify what the expected behavior should be?
0
Brian Sayatovic
Top achievements
Rank 1
answered on 29 Mar 2013, 03:27 PM
Also, do you have any suggested work-arounds?
0
Nedyalko Nikolov
Telerik team
answered on 02 Apr 2013, 07:18 AM
Hello,

The expected behavior should be to have a "23|" text inside RadDateTimePicker if DateTime cell is focused and "23" is entered via keyboard. Unfortunately we've managed to fix this issue for WPF (and I wrote you), but there is a problem with Silverlight (as you know we share a common code base and I do not expect any problems but...). I've just talked with the team responsible for RadDateTimePicker control and they ensured me that this issue will be fixed with high priority, so you could expect a fix with one of the internal builds that follow the upcoming service pack.
Sorry for the inconvenience caused.

Greetings,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Brian Sayatovic
Top achievements
Rank 1
answered on 02 Apr 2013, 12:25 PM
I think there may still be confusion.

My actual problem is not with RadDateTimePicker.  I'm not using a RadDateTimePicker.  If a problem exists with it, I'm not aware of it.

Instead, my problem is with a TextBox.  See my "Amount Used" column here:
<telerik:RadGridView x:Name="MyDataGrid"
    Grid.Row="1"
    AutoGenerateColumns="False"
    ShowGroupPanel="False"
    ShowInsertRow="False"
    IsFilteringAllowed="True"
    RowIndicatorVisibility="Collapsed"
    VerticalAlignment="Stretch"
    ItemsSource="{Binding Path=MyData}"
    ScrollViewer.VerticalScrollBarVisibility="Visible"   
    SelectedItem="{Binding Path=SelectedDataItem, Mode=TwoWay}"
    CanUserInsertRows="False"
    CanUserDeleteRows="False"
    AlternateRowBackground="#008CFFFF"
    HorizontalAlignment="Left"
    TelerikRadGridView:Empty.EmptyDataTemplate="{StaticResource EmptyTemplate}">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="Column A" Width="*" >
            <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                    <TextBlock Foreground="{Binding IsApplicable, Converter={StaticResource ApplicabilityColorConverter}}" Text="{Binding Description}"/>
                </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
        </telerik:GridViewDataColumn>
        <telerik:GridViewDataColumn Header="Amount Available" Width="Auto" >
            <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Foreground="{Binding Available, Converter={StaticResource CurrencyColorConverter}}" Text="{Binding Available, StringFormat=\{0:n2\}}" HorizontalAlignment="Right"/>
                    </StackPanel>
                </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
        </telerik:GridViewDataColumn>
        <telerik:GridViewDataColumn Header="Amount Used" Width="Auto" IsFilterable="False" TextAlignment="Right">
            <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding UsedValue, Converter={StaticResource UsedValueTextConverter}}" HorizontalAlignment="Right" />
                </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
            <telerik:GridViewDataColumn.CellEditTemplate>
                <DataTemplate>
                    <TextBox Text="{Binding UsedValue, Mode=TwoWay, Converter={StaticResource UsedValueTextConverter}}" HorizontalContentAlignment="Right"></TextBox>
                </DataTemplate>
            </telerik:GridViewDataColumn.CellEditTemplate>
        </telerik:GridViewDataColumn>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

When the "Amount Used" column is focused, but NOT in edit mode, and I press a key (e.g. "1"), the cell enters edit mode, its contents are replaced with a string comprised solely of the new key (e.g. "1") and the TextBox's contents are entirely selected.  So as I press the second key (e.g. "2" to try and achieve the string "12" in the TextBox), the contents are *replaced* with the string "2" (because the "1" had been selected).

Now I had assumed this was some bug of mine until I found this old thread.  Earlier in this thread, it was stated, "If this element is a custom control set via CellEditTemplate RadGridView sets focus to the first control which can take focus and if this control is textbox selects all text of it".  I am in fact used a custom CellEditTemplate that is a TextBox, so that behavior I observe seems to match what is described in this thread.

But that behavior is a problem for me.  It means a user can't just start typing on a focused but non-edit-mode cell because their first keystroke will be lost when the subsequent keystrokes start replacing that text due to the autoselect.

The unnatural and frustrating behavior I experience with my TextBox is very much like the RadDateTimePicker behavior in the example I cited.  That is why I mentioned RadDateTimePicker.  But my problem is with RadTextBox.

So let me ask some very direct questions:

  1. Is the following still true: "If this element is a custom control set via CellEditTemplate RadGridView sets focus to the first control which can take focus and if this control is textbox selects all text of it."?
  2. If #1 is true, where is that documented?
  3. If #1 is true, is there a way to STOP that behavior?
0
MiddleTommy
Top achievements
Rank 1
answered on 02 Apr 2013, 02:23 PM
I too have had the same problem with custom columns entering edit mode for years. When you click on the cell to enter edit mode it works perfectly. But when a focused cell has a key press to enter edit mode sometimes the text is highlighted and over written like stated above and sometimes nothing is selected and the text remains the same as before the key press with the caret at the beginning of the textbox.
0
Nedyalko Nikolov
Telerik team
answered on 03 Apr 2013, 08:25 AM
Hi Brian,

Could you confirm that you observe the described behavior with our latest version?
Just for test could you remove the binding converter (or send it to me in order to test on my side).

Indeed RadGridView places focus on the first child element that could take focus and if this is a textbox the entire text is selected. However this is not the case when editing is invoked via key press then selection is places and the end of the text.
We will add this to our documentation.
You could change this behavior by handling RadGridView.PreparedCellForEditevent.

Hi Tommy

I'm sorry to understand that you have problems with editing for years.
Could you please give me a little bit more info about your problem (a sample project will be great)?
I'll be glad to assist.

Regards,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Brian Sayatovic
Top achievements
Rank 1
answered on 04 Apr 2013, 12:42 PM
I tried removing my converter and the problem still existed.

As far as trying the latest controls, I'll have to wait a little bit to try that.  This bug was reported against a release that is undergoing QA.  We never upgrade third party library versions in a QA release.  While Telerik's release are always high quality, we don't have the time to fully regression test everything so late in our QA process.  I'll recommend we slate this bug to be fixed in our next release (currently under development) where it is still open for bigger changes.

FWIW, we're on Q3 2012 (version 2012.3.1314.1050).  The latest is Q1 2013 (should be version 2013.1.xxxx.xxxx).
0
Nedyalko Nikolov
Telerik team
answered on 09 Apr 2013, 10:50 AM
Hello Brian,

Could you please send me the code inside "UsedValueTextConverter"? I'll test it on my side and let you know about the result. We do not have any pending problem with keyboard editing, so I'm very surprised that you have problems with the TextBox editor.
Thank you in advance.

All the best,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
MiddleTommy
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Brian Sayatovic
Top achievements
Rank 1
MiddleTommy
Top achievements
Rank 1
Share this question
or