Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
875
After enter, active record to AddNewRecord special row in edit mode
posted

Hey, I'll ask again.  How can i set the AddNewRecord special row's first cell to be automatically selected and in edit mode after I add a record (by pressing enter key)?  I have AllowAddNew="true" and AddNewRecordLocation="OnBottomFixed".  Surely someone knows how to do this.  I just want the first cell in that special row (with the +) to be ready for user to type in for adding records quickly.

 

private void dp_PreviewKeyDown(object sender, KeyEventArgs e)

{

if (e.Key == Key.Enter)

XamDataPresenter dp = sender as XamDataPresenter;

if (dp != null)

{

set active record/cell to the add row and enter edit mode here how?

}

}

Parents
  • 27093
    posted

    Hello,

     

    I have been looking into this and can suggest you use the RecordAdded and RecordUpdated events to get this functionality like so:

     

    public Record flag;

    private void xamDataGrid1_RecordAdded(object sender, RecordAddedEventArgs e)

    {

        flag = e.Record;

    }

    private void xamDataGrid1_RecordUpdated(object sender, RecordUpdatedEventArgs e)

    {

        if (e.Record == flag)

        {

            e.Record.RecordManager.CurrentAddRecord.Cells[0].IsActive = true;

            xamDataGrid1.ExecuteCommand(DataPresenterCommands.StartEditMode);

            flag = null;

        }

    }

     

     

    Here is a also a code snippet you can use to replace the bolded text in your description:

     

    if ((xamDataGrid1.ActiveRecord!=null) && (xamDataGrid1.ActiveRecord as DataRecord).IsAddRecord)

    {

        xamDataGrid1.ActiveRecord.RecordManager.CommitAddRecord();

        Dispatcher.BeginInvoke(new Action(() =>

        {

            xamDataGrid1.ActiveRecord.RecordManager.CurrentAddRecord.Cells[0].IsActive = true;

            xamDataGrid1.ExecuteCommand(DataPresenterCommands.StartEditMode);

        }), System.Windows.Threading.DispatcherPriority.Background, null);

    }

     

    Please let me know if you require any further assistance on the matter.

     

    Sincerely,

    Petar Monov

    Developer Support Engineer

    Infragistics Bulgaria

    www.infragistics.com/support

     

Reply Children
No Data