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

Is there a property to obtain the current NewRow Entity ?

Thread ID:

Created:

Updated:

Platform:

Replies:

121707 Jan 18,2016 03:24 PM UTC Jan 19,2016 12:53 PM UTC WPF 1
loading
Tags: SfDataGrid
Silvio
Asked On January 18, 2016 03:24 PM UTC

Hi,

I'm binding a SfDatagrid to a detail form using the SelectedItem property, for example in this way:

  SelectedItem="{Binding Path=Selection, Mode=TwoWay}"  

where "Selection" is a suitable member on my ViewModel class.
This works very good.

However when the user is inserting a new record on the grid (using the AddNewRowInitiating event), the SelectedItem property is null.
So I don't have any binding on the detail form to the new created record until the record is really inserted in the datagrid.
But I would like to have a property (or a method) in the datagrid to obtain also the currenctly adding record.
Is there any possibility to obatain this record?

I've also thougth this workaroud. I have this method when I insert a new record:

        private void SfDataGrid_AddNewRowInitiating(object sender, Syncfusion.UI.Xaml.Grid.AddNewRowInitiatingEventArgs args)
        {
          args.NewObject = new CustomerDTO();
        }

I could save this newly created record (CustomerDTO) in a private field of the form. And then define a my own property to return it.
But what event must I join in order to set this field to null when the record is added to the datagrid and it not yet bindend to the "add new Row"?

So what can you suggest me to solve this problem ?

Silvio


Sowndaiyan Paulpandi [Syncfusion]
Replied On January 19, 2016 12:53 PM UTC

Hi Silvio,

Thanks for contacting Syncfusion Support.

We have analyzed your query. You can achieve your requirement “Set the private field CustomerDTO as null” by using the RowValidated event like the below code example,

Code Example [ C# ]


sfdatagrid.RowValidated += sfdatagrid_RowValidated;

void sfdatagrid_RowValidated(object sender, RowValidatedEventArgs args)

{

    if(sfdatagrid.IsAddNewIndex(args.RowIndex))

    {
      
// here you can set your private field as null
        CustomerDTO = null;

     }
}




Regards,

Sowndaiyan


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

;