SfDataGrid Keyboard Editing

I have two questions relating to the SfDataGrid for Xamarin.Forms and would appreciate both answers as C# instead of XAML.

1) How can I submit a null value into a cell? 

I'm using type [double?] and generating the column as follows:

    GridTextColumn Series1Column = new GridTextColumn() {
                MappingName = "Series1",
                HeaderText = "Series1",
    };

I have a strong requirement for a nullable entry. I can't just override 0 because 0 is needed and means something else. Any attempt I make at entering nothing either doesn't save change or will turn it to 0 (GridNumericColumn). I've looked at the virtual methods and I don't really see anything to override.

2) I've got the latest pre-release [16.3.0.17-beta] and it allows me to now navigate with the keyboard through the cells just as I expected it to. Now my issue is how to enter editing on the cell I'm on. I was hoping for a Keydown event that I could capture the EnterKey and grab the current cell, and BeginEdit. My users need to be able to use the keyboard exclusively and not have to reach and grab the mouse anytime they move to a new cell. Is this possible to add a KeyDown event? 

Thanks.

2 Replies

VR Vigneshkumar Ramasamy Syncfusion Team September 25, 2018 03:43 AM UTC

Hi Mark,  
  
We apologies for the delay in the solution.  
  
We have analyzed the query for SfDataGrid Keyboard Editing.  
  
Query1:  
I have a strong requirement for a nullable entry. I can't just override 0 because 0 is needed and means something else. Any attempt I make at entering nothing either doesn't save change or will turn it to 0 (GridNumericColumn). I've looked at the virtual methods and I don't really see anything to override.  
  
You can set the null value to the GridNumericColumn initially by keeping the datatype of the model property as the double? (nullable double). For commiting the null value in the runtime is not possible as now. We are checking the reported use case and we will update you the validation details before end of the 25th September, 2018.  
  
Query 2:  
 I've got the latest pre-release [16.3.0.17-beta] and it allows me to now navigate with the keyboard through the cells just as I expected it to. Now my issue is how to enter editing on the cell I'm on. I was hoping for a Keydown event that I could capture the EnterKey and grab the current cell, and BeginEdit. My users need to be able to use the keyboard exclusively and not have to reach and grab the mouse anytime they move to a new cell. Is this possible to add a KeyDown event?   
  
We have provided the support to enter the edit mode from the current cell focus from the 16.3.0.21 version which is Volume 3. Please update to this version and you can enter into the edit mode by using the F2 Key and commit using the Enter key. For the KeyDown event, you can process the keyDown event from the sample level to achieve your requirement.  
  
Regards,  
Vigneshkumar R 



VR Vigneshkumar Ramasamy Syncfusion Team September 25, 2018 09:48 AM UTC

Hi Mark, 
 
Regarding your query 1, you can commit the null value when editing by setting SfDataGrid.GridNumericColumn.AllowNullValue = true . Please find the code snippet for the same below. 
 
<sfgrid:SfDataGrid.Columns> 
    <sfgrid:GridNumericColumn  
                            AllowNullValue="true" 
                            MappingName="EmployeeID" /> 
    <sfgrid:GridTextColumn MappingName="FirstName"/> 
</sfgrid:SfDataGrid.Columns> 
 
We have prepared the sample as per your requirement, you can download the same from the below link.  
 
Sample LinkSfDataGridSample
 
 
Regards, 
Vigneshkumar R 


Loader.
Up arrow icon