AllowEditing only on last Row

Hello

:Like in topic, i use SfDataGrid to show data.
I want add button. When user click on button, then in SfDataGrid should add new row and only this new row should be allowed (enabled) to edit.
User can add only one row.
How can i reach this goal ?

3 Replies 1 reply marked as answer

MA Mohanram Anbukkarasu Syncfusion Team December 15, 2020 01:04 PM UTC

Hi Marcin, 

Thanks for contacting Syncfusion support.  

You can enable editing for only a specific row disable for all the other rows by using SfDataGrid.CurrentCellBeginEdit event as shown in the following code example.  

Code example :  

<syncfusion:SfDataGrid Name="dataGrid" 
                       ItemsSource="{Binding Employees}" 
                       CurrentCellBeginEdit="DataGrid_CurrentCellBeginEdit"> 

private void DataGrid_CurrentCellBeginEdit(object sender, Syncfusion.UI.Xaml.Grid.CurrentCellBeginEditEventArgs e) 
{ 
    if(e.RowColumnIndex.RowIndex != 1) 
    { 
        e.Cancel = true; 
    } 
} 



Please let us know if you require further assistance from us.  

Regards, 
Mohanram A. 


Marked as answer

MM Marcin Marcinkowski December 15, 2020 03:30 PM UTC

Ok Thanks its work but i have problem with simple Add row programmatically.
I saw this https://help.syncfusion.com/wpf/datagrid/data-manipulation#add-row-programmatically
but i have a lot of problem with that solution for example i dont see
Grid.GetAddNewRowController(); in my grid. 
Also Grid.View.AddNew() doesnt do anything .
Please give me a simplest way to add new row in grid.

p.s. i tried to add new row in collection which i bind with grid but then comboboxes dosent work my sf version is 18.2400.0.44


MA Mohanram Anbukkarasu Syncfusion Team December 16, 2020 02:37 PM UTC

Hi Marcin, 

Thanks for the update.  

We have prepared a sample to add a new row with GridComboBoxColumn in the SfDataGrid. But we are able to use the combobox properly without any issue. The sample we have prepared is available in the following link for your reference. 


Please have a look at this sample and revert to us with details if still you are facing the issue and provide a video/image illustration of the issue you are facing in combobox. 
Regards, 
Mohanram A. 


Loader.
Up arrow icon