Select cell content on focus

Hello,

is it possible to automatically select all text of a data grid cell when it receives the focus in edit mode?
So that the user does not have to delete the current value manually before entering a new value?

Regardless if it receives the focus from navigating with the keyboard (Tab/Enter) or by clicking/double-clicking onto the cell.
I am using the grid in batch edit mode.

Thank you for your effort!
Kind Regards

10 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team January 21, 2021 06:16 AM UTC

Hi Stefan,  
 
Thanks for contacting Syncfusion support.  
 
Query: “is it possible to automatically select all text of a data grid cell when it receives the focus in edit mode? 
 
We have analyzed the query and we have achieved your requirement using OnCellEdit event and JSInterop feature. OnCellEdit event will be triggered whenever a cell goes into edit mode. In that event we have called a JavaScript function to select the text using Select method. Refer the below code example.  
 
<SfGrid AllowPaging="true" DataSource="@Orders" Toolbar="@(new List<string>() { "Add""Edit""Delete""Cancel""Update" })"> 
    <GridEvents OnCellEdit="CellEdit" TValue="Order"></GridEvents> 
    <GridEditSettings AllowEditing="true" AllowDeleting="true" AllowAdding="true" Mode="@EditMode.Batch"></GridEditSettings> 
. . . . .  
</SfGrid>s 
  
  
@code{ 
    public List<Order> Orders { getset; } 
    public void CellEdit(CellEditArgs<Order> Args) 
    { 
        Runtime.InvokeVoidAsync("select", Args.ColumnName); 
    } 
  function select(ele) {        setTimeout(function () {         document.getElementById(ele).select();    }, 100)  }
   
Kindly download the sample which we have prepared using above solution from below 
 
 
Refer our UG documentation for your reference 
 
 
Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan 


Marked as answer

ST Stefan January 21, 2021 02:58 PM UTC

Vignesh,

your solution works like a charm, thx for your effort! :-)

Kind Regards


VN Vignesh Natarajan Syncfusion Team January 22, 2021 03:23 AM UTC

Hi Stefan,  

Thanks for the update.  

We are glad to hear that you have achieved your requirement using our solution.  

Please get back to us if you have further queries. 

Regards, 
Vignesh Natarajan  



ND Noel Dacara replied to Vignesh Natarajan March 26, 2022 12:19 PM UTC

It would be best if this functionality be applied as built-in feature on grid.

This should be set as default for numeric typed cells, editing on grid would be more user-friendly with this.

There is literally no one that edits a number and just appends in the end, users will always replace the entire value.



RN Rahul Narayanasamy Syncfusion Team March 28, 2022 03:02 PM UTC

Hi Noel, 

Greetings from Syncfusion. 

We are currently checking the reported query from our end and we will update the further details within three business days. Until then we appreciate your patience. 

Regards, 
Rahul 



RN Rahul Narayanasamy Syncfusion Team March 31, 2022 01:41 PM UTC

Hi Noel,


Thanks for your patience.


We have considered your requirement as an improvement and logged the feature task “Need to select the content in the edit form when grid goes to edit state” for the same. Thank you for taking the time to report this issue and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle) and including the feature in any of our upcoming releases. Until then we appreciate your patience.


You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.     


https://www.syncfusion.com/feedback/23634/need-to-select-the-content-in-edit-form-when-the-grid-goes-to-edit-state


Regards,

Rahul



SZ Szoke replied to Rahul Narayanasamy February 22, 2023 03:35 PM UTC

Hello ! Is it possible to know the solution to the above proposal?



NP Naveen Palanivel Syncfusion Team March 2, 2023 02:09 AM UTC

Hi Szoke,


We understand that ,you want to select the content of the Edit cell when grid goes to edit state. We have work around solution to achieve your requirement using javascript. Please refere the codesnippet and sample for more reference. We would also like to convey, We do not have built in support and considered your requirement as an improvement and logged the feature task “Need to select the content in the edit form when grid goes to edit state” for the same. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle) and including the feature in any of our upcoming releases. Until then we appreciate your patience.


You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.     


https://www.syncfusion.com/feedback/23634/need-to-select-the-content-in-edit-form-when-the-grid-goes-to-edit-state



SfGrid AllowPaging="true" DataSource="@Orders" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">

    <GridEvents OnCellEdit="CellEdit" TValue="Order"></GridEvents>

 

public List<Order> Orders { get; set; }

    public void CellEdit(CellEditArgs<Order> Args)

    {

        Runtime.InvokeVoidAsync("select", Args.ColumnName);

    }

 

 

JavaScript

 

function select(ele) {

   setTimeout(function () {

        document.getElementById(ele).select();

    }, 100)

}

  


Please let us know if you have any concerns.


Regards,

Naveen Palanivel


Attachment: EditContent_4a9ca4e7.zip


KD Kiran Dwarakapuram January 18, 2024 04:39 PM UTC

Is this added to grid as built-in functionality or still need to use JSInterop? The feedback link is not available for me to check status.



PS Prathap Senthil Syncfusion Team January 22, 2024 12:19 PM UTC

Hi Kiran,

We haven't implemented this feature yet, so you can use the JS solution. We do not have an immediate plan to implement this requirement “Need to select the content in the edit form when grid goes to edit state”. At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technological feasibility, and customer interest.


You can also communicate with us regarding the open feature at any time using our above feedback report page. Please cast your vote to make it count. So we will prioritize the improvement for every release based on demands and this improvement will be included in any of our upcoming releases. 


You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this feedback link.


Regards,
Prathap S


Loader.
Up arrow icon