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

Select all text when cell starts edit

3 Answers 439 Views
DataGrid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 26 Nov 2019, 11:20 PM
When starting a cell edit, it is desired to have all the text selected, so the user can easily replace the current text without having to delete it.  From the docs, I do not see how to make this work.  Is it possible to get the current edit control that is attached to the cell during begin edit?

3 Answers, 1 is accepted

Sort by
0
Alex
Telerik team
answered on 29 Nov 2019, 02:29 PM

Hi John,

Currently, the RadDataGrid does not provide this functionality, so I have logged a feature request on your behalf in our feedback portal. You can follow and vote for the item and the link below: 

https://feedback.telerik.com/xamarin/1444321-datagrid-provide-an-option-to-select-all-text-when-cell-starts-edit

Please find your Telerik points updated as a small sign of gratitude for your involvement.

Let me know if I can assist with anything else.

Regards,
Alex
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
John
Top achievements
Rank 1
answered on 11 Dec 2019, 03:42 PM

Looking at the example app, it looks like there is a way to do this through the entry.

 

Is there a way to create a template column using entries? If so, here is my situation:

 

I have a on single tap event for when going into a numerical cell. That single tap is to prevent the need for a doubletap, is there a way to single tap into an entry (that is within the template column in the datagrid) and use the same logic to select all characters?

 

Here is my code for the single tap:

public class EditSingleClickCommand : DataGridCommand
{
    private readonly RadDataGrid _dataGrid;
    public EditSingleClickCommand(RadDataGrid dataGrid)
    {
        _dataGrid = dataGrid;
        Id = DataGridCommandId.CellTap;
    }
 
    public override bool CanExecute(object parameter)
    {
        return parameter is DataGridCellInfo;
    }
 
    public override void Execute(object parameter)
    {
        DataGridCellInfo info = (DataGridCellInfo)parameter;
        _dataGrid.CommandService.ExecuteDefaultCommand(DataGridCommandId.CellTap, parameter);
        EditContext editContext = new EditContext(info, ActionTrigger.Tap, null);
        _dataGrid.CommandService.ExecuteDefaultCommand(DataGridCommandId.BeginEdit, editContext);
    }
}

 

 

Thanks in advance!

0
Lance | Manager Technical Support
Telerik team
answered on 11 Dec 2019, 06:54 PM

Hello John,

If you're going to move forward with TemplateColumn, this means you have access to the UI element directly and don't need to use DataGrid commands (also, the edit command will never fire for TemplateColumn as it is not an editable column).

Instead, you can use general Xamarin.Forms development techniques to interact and use the Xamarin.Forms elements inside that template.

To directly answer your question of how to perform a 'select all on focus' with a Xamarin.Forms Entry control, see this StackOvberflow thread - https://stackoverflow.com/questions/28194231/automatically-select-all-text-on-focus-xamarin/ 

I personally like the answer that uses Xamarin.Forms 4.2 Focus event because you won't need a custom renderer.

 

A word of caution

As I mentioned above, TemplateColumn was not intended or designed to be an editable cell. Its purpose is to display data that doesn't need to be edited (e.g. an Image). If you use it to act as a batch edit cell and circumvent the built-in editing features/lifecycle, you may find unexpected behavior. Please test your app carefully.

Regards,
Lance | Team Lead - US DevTools Support
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
John
Top achievements
Rank 1
Answers by
Alex
Telerik team
John
Top achievements
Rank 1
Lance | Manager Technical Support
Telerik team
Share this question
or