Hi there,
I'm trying to get XamDataGrid to trigger AddNewCore after pressing the Plus.
With the code provided I am able to activate a new record after pressing Plus but AddNewCore is not called at this time.
What can I do to create this behaviour?
Thanks in advance.
Code:
dataGrid.RecordActivated += new EventHandler<Infragistics.Windows.DataPresenter.Events.RecordActivatedEventArgs>(dataGrid_RecordActivated); void dataGrid_RecordActivated(object sender, Infragistics.Windows.DataPresenter.Events.RecordActivatedEventArgs e) { (dataGrid.ActiveRecord as DataRecord).Cells[0].IsActive = true; dataGrid.ExecuteCommand(DataPresenterCommands.StartEditMode); }
Great Alex,
you are fantastic! :)
Works like a charm.
Thanks again,
Patrick
Hello Patrick,
Currently, I believe there is no direct way of forcing the XamDataGrid to invoke the default constructor. What you can do to show the default values is the following :
void xdg_EditModeStarted(object sender, Infragistics.Windows.DataPresenter.Events.EditModeStartedEventArgs e)
{
if (e.Cell.Record.IsAddRecord && e.Cell.Record.DataItem == null)
object oldVal = e.Editor.Value;
e.Editor.Value = null == oldVal ? DBNull.Value : null;
e.Editor.Value = oldVal;
}
Hi Alex,
the code does almost work.
It selects the first column and activates it, but the Method AddNewCore() is not called so our objects default values are not filled until we have a keystroke in one of the fields.
We are using v10.2 of the XamDataGrid.
Thanks in advance,
Hello,
I tried your code and it works correctly. The cell enters edit mode when the record selector is pressed. Can you please tell us which version and build of our controls you are using ?
Thank you!