Select all text when cell starts edit

4 posts, 0 answers
  1. John
    John avatar
    9 posts
    Member since:
    Mar 2015

    Posted 26 Nov 2019 Link to this post

    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?
  2. Alex
    Admin
    Alex avatar
    3 posts

    Posted 29 Nov 2019 Link to this post

    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
  3. John
    John avatar
    9 posts
    Member since:
    Mar 2015

    Posted 11 Dec 2019 in reply to Alex Link to this post

    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!

  4. Lance | Manager Technical Support
    Admin
    Lance | Manager Technical Support avatar
    1195 posts

    Posted 11 Dec 2019 Link to this post

    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
Back to Top