Good day
We want to enter data like one would do in excel.
data (press enter and go to next record same field)
something like that. From what I have read, I would have to create it in a enter button event. Is this correct? This functionality is not supported in the XamDataGrid itself, right?
Kind regards
Christo Labuschagne
Hello Andre,
You can execute the EndEditModeAndAcceptChanges DataPresenterCommand. You can pass it as a parameter to the XamDataGrid's ExecuteCommand method.
I have a followup to this question. I am trying to exit the edit mode programmatically (ie. force XamDataGrid to exit edit mode) but do this from ViewModel instead of code behind. What is the best way to do this?
Thanx Alex
Like always, quick and accurate! Here is what I did:
private void xamDataGrid1_EditModeEnded(object sender, Infragistics.Windows.DataPresenter.Events.EditModeEndedEventArgs e) { xamDataGrid1.ActiveRecord = xamDataGrid1.Records[e.Cell.Record.Index + 1]; DataRecord myRecord = (DataRecord)xamDataGrid1.ActiveRecord; CellValuePresenter cvp = CellValuePresenter.FromRecordAndField(myRecord, e.Cell.Field); cvp.StartEditMode(); }
Thanx again
Regards
Christo
Hello Christo,
You are right, this is not directly supported. There are couple of ways to achieve this though. The XamDataGrid has many events that you can use to go on the next record and start edit mode. Basically, any event that would exit the cell's edit mode would do the trick:
1. CellUpdating, CellUpdated events
2. EditModeEnding, EditModeEnded
3. You can handle the KeyDown event of the editor in the cell or the CellValuePresenter itself.
In order to start the edit mode of the next line, you can use DataPresenterCommands -
for example: xamDataGrid1.ExecuteCommand(DataPresenterCommands...);
You can also start edit mode from the CellValuePresenter object (you can get it by the static method CellValuePresenter.FromCell(...).
Let me know if you have questions on this.