Custom Tab Focus Direction in SfDataGrid
I am Facing Issue With SfDatagrid. i have changed the flowdirection of SfDatagrid to Right To Left. In That case i want to move focus direction of cell from right to left on Tab Key Press. I tried to achieve that by overridding ProcessKeyDown.
I also applied OnRowValidating Event in my SfDataGrid(which gets fired on row change)
My problem is that when i am on right most column of sfdatagrid (Note:Flowdirection of sfdatagrid is right to left) and pressing tab key then before navigating to left direction cell from right,
OnRowValidation Event gets fired.
I am working in Application thats worked in two language (English and Arabic.) Everything is fine with English. But in case of arabic
Direction of SfDatagrid should be right to left and so focus direction of cell also from right to left
SIGN IN To post a reply.
6 Replies
JN
Jayaleshwari N
Syncfusion Team
January 7, 2019 12:04 PM UTC
Hi Yogendra,
Thanks for contacting Syncfusion Support.
We have analyzed your query ”Custom Tab Focus Direction in SfDataGrid” from our side and We have prepared sample based on the provided information. We have tried to reproduce your reported problems with the simple sample.
1. OnRowValidating event gets fired when apply the navigation from the right most column
2. Right to Left tab key navigation not working properly for Arabic language.
But unfortunately, the reported issue does not replicate at our end.
We have attached the tested sample for your reference and you can download the same from the following location.
Sample link: SelectionDemo-512575348.zip
Could you please check with the above sample whether the reported issue reproduced in our sample also.? If not , we would request you to share the customization codes to us for tab key navigation? Which would be help us to work further on your reported issue.
Regards,
Jayaleshwari N
YO
yogendra
January 8, 2019 05:44 AM UTC
Hi ,Thanks to Response. I have checked the solution provided by you. I applied validation rule on Row for Second column from left side of sfdatagrid and set the debug point to DataGrid_RowValidating event.
Attachment: SelectionDemo_8fbcd71f.zip
I am still facing the same issue, when i am pressing tab key when focus is on left most column then "DataGrid_RowValidating " event getting raised before navigating to next left column.
I have Attached the Modified Solution. Please Check and please set the cell in edit mode before pressing tab
Thanks Regards
Yogendra
Attachment: SelectionDemo_8fbcd71f.zip
Hi ,Thanks to Response. I have checked the solution provided by you. I applied validation rule on Row for Second column from left side of sfdatagrid and set the debug point to DataGrid_RowValidating event.I am still facing the same issue, when i am pressing tab key when focus is on left most column then "DataGrid_RowValidating " event getting raised before navigating to next left column.I have Attached the Modified Solution. Please Check and please set the cell in edit mode before pressing tabThanks RegardsYogendra
Attachment: SelectionDemo_8fbcd71f.zip
Please Check the Screenshot also
Attachment: Screenshot_dc10fc7d.zip
JN
Jayaleshwari N
Syncfusion Team
January 9, 2019 12:21 PM UTC
Hi Yogendra,
Thanks for the update.
In SfDataGrid the RowValidating event occurs when edited cells tries to commit the row data or lose the focus. And when you try to move one row to next row by using the Tab key navigation in this case RowValidating event gets fired on the apply tab key navigation in Last column Index. This is the behavior of SfDataGrid.
In your case you Customize the Tab key navigation in ProcessOnKeyDownEvent to apply the navigation Right to Left. We suspect your customization codes calls the RaiseRowValidate method in ProcessOnKeyDown event. And this is the cause of RowValidating event gets trigged when you are pressing the tab key.
And you can avoid that by using the below code snippets.
|
public class GridCellSelectionControllerExt : GridCellSelectionController
{
public GridCellSelectionControllerExt(SfDataGrid dataGrid) : base (dataGrid)
{
}
protected override void ProcessKeyDown(KeyEventArgs args)
{
if (args.Key == Key.Tab)
{
int rowIndex, columnIndex;
if (CurrentCellManager.CurrentRowColumnIndex.RowIndex <= this.DataGrid.GetHeaderIndex() && !(this.DataGrid is DetailsViewDataGrid))
return;
var rowColumnIndex = this.CurrentCellManager.CurrentRowColumnIndex;
if (!args.Handled)
{
rowIndex = CurrentCellManager.CurrentRowColumnIndex.RowIndex;
columnIndex = CurrentCellManager.CurrentRowColumnIndex.ColumnIndex;
bool isLastColumnIndex = columnIndex == this.DataGrid.Columns.Count;
object isValidationRaised = null;
if (isLastColumnIndex)
{
var vaildationHelper = this.DataGrid.GetValidationHelper();
var raiseValidateMethod = vaildationHelper.GetType().GetMethod("RaiseRowValidate", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
isValidationRaised = raiseValidateMethod.Invoke(vaildationHelper, new object[] { CurrentCellManager.CurrentRowColumnIndex });
}
if (isValidationRaised != null && !(bool)isValidationRaised)
{
args.Handled = true;
return;
}
if (isLastColumnIndex)
{
int index = rowIndex + 1;
if (index > this.DataGrid.View.Records.Count)
index = 1;
rowColumnIndex = new RowColumnIndex(index, 1);
}
else
{
rowColumnIndex = new RowColumnIndex(rowIndex, columnIndex + 1);
}
this.DataGrid.SelectionController.MoveCurrentCell(rowColumnIndex,true);
}
}
else
{
base.ProcessKeyDown(args);
}
}
} |
We have attached the tested sample for your reference and you can download the same from the following location.
If still the issue is not resolved in your application then kindly share your ProcessOnKeyDown customization codes, it will help us to provide the better solution as much earliest.
Regards,
Jayaleshwari N
YO
yogendra
January 10, 2019 06:11 AM UTC
Thanks . Its Working Fine
JN
Jayaleshwari N
Syncfusion Team
January 11, 2019 10:13 AM UTC
Hi Yogendra,
Thanks for the update. Please get in touch if you would require for further assistance.
Regards,
Jayaleshwari N.
SIGN IN To post a reply.
- 6 Replies
- 2 Participants
-
YO yogendra
- Jan 3, 2019 06:55 AM UTC
- Jan 11, 2019 10:13 AM UTC