I am a bit confused about validating an added record via xamdatagrid
AllowAddNew
="True" AddNewRecordLocation="OnBottomFixed"
I do not want to add the record until I inspect and validate the values. The RecordAdding or RecordAdded event handlers seem to offer me no such way to do this.
Any suggestions?
Hello,
One of the specific allowAddNew property is that works with the default constructor of your class. As soon as you write something in the AddNewRecordLocation a new record is added to your list and after pressing enter it is being updated...
You can loop through all the records and inspect them, except the record that is currently in the process of adding with a simple if clause like this
foreach(Record r in xamDataGrid1.Records) { if(r != xamDataGrid1.RecordManager.CurrentAddRecord) {
// inspect records
} }
or just inspect all the records, except the last one ( as the added record in the last position).
Then you can delete the newly added record ( by getting the reference from the RecordManager again) if the inspection fails.Does this work in your scenario?
Prior to adding a new record I need to look at the previous collection in the grid and inspect it.
In the RecordUpdating Event I am retriving a collection of items from the xamdatagrid. I've tried RecordManager.DataPresenter.DataSource or xamdatagrid.DataSource and surprisingly the new record is already there. I want to inspect the record BEFORE adding it. It seems that the recordupdating event fires AFTER the record has been added. I am still at square one....
You can use xamDataGrid1.RecordManager. This way you can get reference of the adding/added record and perform your validation in RecordUpdating event.
Hope this helps
Alex.