commit addnewrow before save modification

Hello,

I have an application with a datagrid with addnewrow enabled and ribbon button.

The ribbon button is binding to command that save data to some back end.

My problem is that when the command is called the new row is not commit and  observableCollection don't have the new line.

i have two solutions

- force the commitnewrow before call the backend 

-or disable the command when datagrid have current add item not commited


Benjamin




Attachment: DatagridGridTextColumnReadonly_617623bf.zip

3 Replies 1 reply marked as answer

MA Mohanram Anbukkarasu Syncfusion Team October 6, 2021 03:09 PM UTC

Hi Benjamin, 

Thanks for contacting Syncfusion support.  

We have checked the provided sample. You can achieve your requirement to force commit the new row when clicking on the save button as shown in the following code example.  

Code example :  

if (dataGrid.View != null && dataGrid.View.IsAddingNew) 
{ 
    dataGrid.View.CommitNew(); 
 
    var addNewRow = dataGrid.RowGenerator.Items.FirstOrDefault(item => item.RowType == RowType.AddNewRow); 
    if (addNewRow != null) 
    {  
        addNewRow.RowData = dataGrid.View.CurrentAddItem;  
    } 
 
    dataGrid.ClearSelections(false); 
} 



Please let us know if you require any other assistance from us.  

Regards, 
Mohanram A. 


Marked as answer

BM Benjamin Moiroud replied to Mohanram Anbukkarasu October 7, 2021 09:28 AM UTC


Hi,

Thanks for the answer

In Fact, I solve my problem using IEditableObject and disable the command when a line inside the datagrid is in edit mode.





MA Mohanram Anbukkarasu Syncfusion Team October 8, 2021 05:54 AM UTC

Hi Benjamin, 

Thanks for the update.  

We are glad to know that you have found a solution for the reported problem. Please let us know if you require any other assistance from us.  

Regards, 
Mohanram A. 


Loader.
Up arrow icon