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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

After Adding New Row, force it to commit

Thread ID:

Created:

Updated:

Platform:

Replies:

107902 Mar 21,2013 05:51 PM May 14,2013 06:20 AM WPF 1
loading
Tags: GridControl
Paul McCranie
Asked On March 21, 2013 05:51 PM

I am using the Syncfusion DataGrid. It has an empty row at the top to Add New Records. If I add a new record and then click on another row, it WILL save it. If I click away from the grid after adding a new record, it will not save.

I need the code that will force the datagrid to commit that new row that was created without forcing my users to click on another row or even expecting them to hit enter.

I want to programmtically force the grid to save the new row.

Thanks!

Rajasekar G [Syncfusion]
Replied On May 14, 2013 06:20 AM

Hi Paul,

 

Thanks for the patience.

 

We have analyzed your query and we have achieve your requirement by using the following code snippet.

 

Code Snippet[C#]:

this.AssociatedObject.CurrentCellChanged += new Syncfusion.Windows.ComponentModel.GridRoutedEventHandler(AssociatedObject_CurrentCellChanged);
void AssociatedObject_CurrentCellChanged(object sender, Syncfusion.Windows.ComponentModel.SyncfusionRoutedEventArgs args)
{
    int rowindex = this.AssociatedObject.Model.CurrencyManager.CurrentCell.RowIndex;
    int columnindex = this.AssociatedObject.Model.CurrencyManager.CurrentCell.ColumnIndex;
    var style = this.AssociatedObject.Model[rowindex, columnindex] as GridDataStyleInfo;
    if (style.CellIdentity.TableCellType == GridDataTableCellType.AddNewRecordCell && columnindex == this.AssociatedObject.Model.ColumnCount - 1)
    {
        //you can commit the added new record by using the following code snippet
        if (this.AssociatedObject.Model.CurrencyManager != null)
            this.AssociatedObject.Model.CurrencyManager.EndEdit();
    }            
}

 

 

For your reference we have prepared a sample based on this and it can be download from the following location.

 

Sample Location: GridDataControl_AddNewRow.zip

 

Please let us know if you have any questions.

 

Regards.,

Rajasekar


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;