Highlighting the edit row when selected

When I click on a row to edit the cursor is behind the text and I have to highlight and delete the text rather than type.

How can I have the entire text highlighted when I initiate an edit action


3 Replies 1 reply marked as answer

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team August 30, 2021 05:05 PM UTC

Hi Zachary, 

Greetings from Syncfusion Support. 

Query#:- How can I have the entire text highlighted when I initiate an edit action 
 
We have achieved your requirement using actionBegin event of the TreeGrid. In this event we have get the corresponding Input element and highlight the entire text using select method while editing when requestType as beginEdit. 
 
Refer to the code below:- 
App.Component.html:- 
 
<ejs-treegrid [dataSource] = 'data' height = '400' childMapping = 'subtasks'[treeColumnIndex] = '1' 
        [editSettings] = 'editSettings'[toolbar] = 'toolbar'(actionBegin) = "actionBegin($event)" > 
        <e-columns> 
            <e-column field='taskID' headerText='Task ID' width='70' textAlign='Right' isPrimaryKey='true' 
                [validationRules]='taskidrules'></e-column> 
           .     .   . 
 
</ejs-treegrid > 
 
App.Component.ts 
 
export class AppComponent { 
            public data: Object[] = []; 
 
             
            actionBegin(args) { 
                if ((args.requestType = 'beginEdit')) { 
                    setTimeout(() => { 
                        var element = args.cell.querySelector('input');  //get the Input element 
                        if (!isNullOrUndefined(element)) { 
                            element.select();  //highlight using select method 
 
                        }   
                    }, 10); 
                } 
            } 

 
Please get back to us if you need any further assistance. 

Regards, 
Farveen sulthana T 


Marked as answer

ZA Zachary August 30, 2021 08:19 PM UTC

It works. Thank you!



FS Farveen Sulthana Thameeztheen Basha Syncfusion Team August 31, 2021 08:07 AM UTC

Hi Zachary,   
 
Thanks for your update. Please get back to us if you need any further assistance. We are happy to assist you.  
 
Regards,  
Farveen sulthana T  


Loader.
Up arrow icon