Set Focus to a Grid

Hi,

I have noticed that for a control such as SfTextBox, I can set focus to the text box using SfTextBox.FocusIn.

It appears that SfGrid does not have this same functionality

Can you please either adding FocusIn / FocusOut to the data grid, as I feel that I should be able to set focus to any data entry control.

Regards,
Jeremy

3 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team September 14, 2020 10:22 AM UTC

Hi Jeremy, 
 
Thanks for contacting Syncfusion support.   
  
Query: “Can you please either adding FocusIn / FocusOut to the data grid, as I feel that I should be able to set focus to any data entry control.”  
  
We have analyzed your query and we understand that you want to focus the Grid on user interaction. Grid can be focused using Alt + J key combination. Currently we are facing some issues with that combination. Hence we are not able to focus the grid. We have confirmed it is a bug and logged the defect report for the same “Not able to focus the Grid”. Thank you for taking the time to report this issue and helping us improve our product .Fix for the issue will be included in our weekly patch release which is expected to be rolled by mid of October 2020      
  
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.      
  
  
Till then we suggest you to use the below workaround to resolve the reported query. We have used Created event of the grid to store the Grid Id in JavaScript method. And we have added keydown event to document page. We have focused the grid element using focus() JavaScript method. So kindly use the Alt + J key combination to focus the Grid. 
 
<SfGrid @ref="Grid" DataSource="@Orders" AllowPaging="true"> 
    <GridEvents Created="Created" TValue="Order"></GridEvents> 
    <GridPageSettings PageSize="5"></GridPageSettings> 
. . . . . . . 
</SfGrid> 
  
@code{ 
    public List<Order> Orders { getset; } 
    SfGrid<Order> Grid { getset; } 
    public void Created() 
    { 
        RunTime.InvokeVoidAsync("Focus", Grid.ID); 
    } 
[Focus.js] 
 
var gridElement; function Focus(id) {    gridElement = id;} document.addEventListener("keydown"function (e) {    if (e.altKey && e.keyCode === 74) { // j- key code.        if (gridElement !== null)            document.getElementById(gridElement).focus();    }});
 
      
For your convenience we have prepared a sample which can be downloaded from below 
 
 
Please get back to us if you have further queries.     

Regards,  
 
Vignesh Natarajan  
 



JE Jeremy September 15, 2020 09:50 AM UTC

Thanks Vignesh,

I am a little confused by your response though.

SfTextBox has the following function ...

//
// Summary:
//     Sets the focus to TextBox component for interaction.
[AsyncStateMachine(typeof(<FocusIn>d__137))]
public Task FocusIn();

Can the same function be made available for the grid please? I thought the idea was to make all of the controls as simple as possible for developers to use, and I feel that - as a developer - being able to use code like

SfGrid.FocusIn();

seems to be a very simple and easy to use implementation.

Regards,
Jeremy








VN Vignesh Natarajan Syncfusion Team September 16, 2020 11:49 AM UTC

Hi Jeremy,  
 
Sorry for the inconvenience caused.  
 
Query: “Can the same function be made available for the grid please? able to use code like && seems to be a very simple and easy to use implementation. 
 
We have analyzed your query and we understand that you want to focus the grid on external action. Currently we do not have support for your requirement. But we have considered your requirement as usability feature and logged the improvement “Method to Focus a grid”. We are always trying to make our products better and feature requests like yours are a key part of our product growth efforts. Fix for the improvement will be included in our 2020 Volume 3 release which is expected to be rolled out by month end of September 2020.  
    
You can also communicate with us regarding the open features any time using our Feature Report page.    
    
 
Till then we appreciate your patience.  
 
Regards, 
Vignesh Natarajan 
 


Marked as answer
Loader.
Up arrow icon