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
close icon

Commit row and navigate to first column of New Row

Hi,

When the TAB key is pressed, it moves the cell from left to right. When the last focusable cell is reached and the TAB key is pressed, it commits any changes and navigates to the first column of the next row.

This works well for my users when the datagrid has pre existing rows.

When the user is adding data to a new row (AddRow = Bottom), I need to commit the row changes and navigate to the Add New Row again with the cell focused at the first column.

Any help on how to achieve this would be great.

Regards,

7 Replies

SP Sowndaiyan Paulpandi Syncfusion Team November 13, 2015 05:58 AM UTC

Hi Brett,

Thanks for contacting Syncfusion Support.


We have analyzed your query and you can achieve your requirement “Commit row and navigate to first column of New Row” by overriding the GridSelectionController class and setting it to the SfDataGrid.SelectionController property.

We have prepared a work around sample as per your requirement and you can download the sample form the following KB location,

KB Link : https://www.syncfusion.com/kb/4736/how-to-move-the-currentcell-to-the-first-column-of-the-addnewrow-when-the-tab-key-is-pressed-from-the

Please let us know if you need further assistance.

Regards,
Sowndaiyan






BK Brett Klopfer November 15, 2015 11:31 PM UTC

Hi,

I have downloaded your sample provided, however it does not compile against SF libraries 13.3.0.12. (errors in CustomSelectionController.cs Lines 32, 56)

After I made some changes to your code to get it to compile, it works ok.

In my application, often the last columns are not editable or focusable because they are auto calculated totals, etc. If I change your sample application to have the last column as AllowFocus = False, the tab key navigation stops working.

Regards

Brett


SR Sivakumar R Syncfusion Team November 16, 2015 08:00 AM UTC

Hi Brett,

Sorry for the inconvenience caused. Please find the modified sample from below location,
http://www.syncfusion.com/downloads/support/directtrac/general/ze/WPF1042640007.zip

KB also modified to work with latest version,

Thanks,
Sivakumar


BK Brett Klopfer November 16, 2015 10:55 PM UTC

Hi,

Thank you for the update. The code now compiles and works.

However, if I set the last column in the datagrid to AllowFocus="False", the tab key behaviour doesn't go to the new line.

<syncfusion:SfDataGrid Name="SfdataGrid"
                       AddNewRowPosition="Bottom"
                       AllowFiltering="True"
                       AllowDraggingColumns="True"
                       AllowEditing="True"
                       SelectionMode="Single"
                       ColumnSizer="Auto"
                       AutoGenerateColumns="False"
                       ItemsSource="{Binding Employee}"
                       NavigationMode="cell">
            <syncfusion:SfDataGrid.Columns>
                <syncfusion:GridTextColumn HeaderText="Employee ID" MappingName="EmployeeID" AllowFocus="True" />
                <syncfusion:GridTextColumn HeaderText="Employee Name" MappingName="Name" />
                <syncfusion:GridTextColumn MappingName="NationalIDNumber" />
                <syncfusion:GridTextColumn MappingName="ContactID" />
                <syncfusion:GridTextColumn MappingName="Title"  />
                <syncfusion:GridDateTimeColumn MappingName="HireDate" />
                <syncfusion:GridDateTimeColumn MappingName="BirthDate" />
                <syncfusion:GridNumericColumn MappingName="Salary" AllowFocus="False" />
            </syncfusion:SfDataGrid.Columns>
        </syncfusion:SfDataGrid>

Regards,

Brett


SP Sowndaiyan Paulpandi Syncfusion Team November 17, 2015 09:33 AM UTC

Hi Brett,

We have analyzed your query. We have prepared a sample to achieve your requirement and you can download the sample from the following location,

Sample Location : http://www.syncfusion.com/downloads/support/forum/121133/ze/TAB_Key_Sample1632028930    
 
In this sample, we have moved the CurrentCell position to next focused column based on the GridColumn.AutoFocus property.

Regards,
Sowndaiyan



BK Brett Klopfer November 17, 2015 10:23 AM UTC

Hi,

It still doesn't work as I expect.

When I am in the AddNewRow and the last column is set to not focusable, the tab key goes back to the first column on the AddNewRow.

All I want is when I am ADDING a new row on the AddNewRow and press TAB on the last focusable column, the row is committed and the focus is bought back to the first column on the NEW AddNewRow row.


SP Sowndaiyan Paulpandi Syncfusion Team November 18, 2015 12:42 PM UTC

Hi Brett,

Sorry for the inconvenience caused.


We have analyzed your query. We have prepared a sample to achieve your requirement and you can download the sample from the following location,

Sample Location : http://www.syncfusion.com/downloads/support/forum/121133/ze/TAB_AddNewRow851091578

Please let us know if you need further assistance.

Regards,
Sowndaiyan




Loader.
Live Chat Icon For mobile
Up arrow icon