We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

how to select the text automatically when the user starts editing a cell in the grid

Hi there!

i'm using a grid and i need that the text get selected automatically when user want edit the cell (when the cell is modified to edit mode.).
i've tried to use BeginEdit method, but without success, cause appear that the text is selected, but some event after my intervenção unselect the text.





Thank so mutch!


Guilherme



3 Replies

MF Mohammed Farook J Syncfusion Team December 17, 2018 09:48 PM

Hi Guia, 
 
Thanks for contacting Syncfusion support. 
 
Query : i need that the text get selected automatically when user want edit the cell (when the cell is modified to edit mode.) 
 
We have analyzed your query and we have found that the event name is given incorrectly in the grid. So we suggest to use the cellEdit event of the grid and using select() method in the setTimeout method you can select the input text. Please refer to the below sample and documentation for your reference, 
 
Code Example: 
 
[.cshtml] 
... 
    @Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.datasource).Columns(col => 
{... 
}).AllowPaging().CellEdit("cellEdit").EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Batch); })...}).Render() 
 
 
<script> 
    function cellEdit(args){ 
        setTimeout(function selectText() { 
            this.cell.querySelector('input').select(); 
        }.bind(args), 0); 
    } 
</script> 
... 
 
 
 
Please get back to us for further assistance. 
 
 
Regards, 
J Mohammed Farook 



GU Guia December 18, 2018 03:03 AM

Hi!!

The code worked perfectly! Thank you very much for your attention.

Regards
Guilherme


MF Mohammed Farook J Syncfusion Team December 18, 2018 03:12 AM

Hi Guilherme 
 
Thanks for your update. 
 
We are happy to hear that the provided solution has been resolved your problem. 
 
Please get back to us if you need further assistance. 
 
Regards 
J Mohammed Farook 


Loader.
Live Chat Icon For mobile
Up arrow icon