We're using the XamDataGrid with 'LoadOnDemand'. We have a couple of custom ICondition classes that check to see whether a record has errors or not. For example, we have a RecordHasErrorsCondition that checks to see if either the parent record or, optionally, any of it's child records currently has an error. However, when child records exist, this condition can take a long time to execute the first time, if none of the child records have been previously loaded. However, the only way, any of the records could have an error is if the user has loaded and edited them, so what we'd like to do is skip records that have yet to be loaded or initialized. I see that the record's DataPresenter has an IsLoaded and IsInitiliazed property, but every time I check these properties, they're true [probably because I'm iterating the records which causes them to be loaded and initialized]. Anyway, is there a way for me to programatically check whether a record has been loaded previously, or maybe from the parent level, determine if it's child records have ever been expanded or loaded? If it has been, we'll check for errors, otherwise, we'll skip the child record(s)...
Hi,
I am just checking have you been able to resolve your issue? If you have any further questions or concerns on this, please do not hesitate to ask.
Hello,
In the XamDataGrid there is a method GetRecordsInView() which returns an array with all the records that are currently in view. You can try to handle the RecordsInViewChanged and set the Tag property of every record that is currently in the collection returned by GetRecordsInView(). If you do this, you will mark all of the data that had been already shown to the user and you can do the validation only over it.
Hope this suits your scenario better. If you have any further questions on this please do not hesitate to ask.
Sorry, I did not initially see your comment. I don't believe that would work in my case as I am trying to determine whether a record contains an error within the implementation of a RecordFilter (I implemented my own ICondition class). I could probably set up my own knowledge of whether or not a record has been previously loaded during record initialization, but I was trying to keep the ICondition class as generic as possible. I only wanted the class to depend on the Record and Cell and whatever properties they expose directly. Like I said, for now, since my data source is a DataView, I can get to the information I need.
Since my data source item is a DataRowView, I'm able to just check the data source for errors instead for now, but it would still be nice to know if there's a way to determine if a row has been previouslyy loaded. 1) It would speed my filter up to not bother with rows that haven't been previously loaded. 2) I may, at some point in the future, need to do this for a data source item that does not store its own error information.
I reviewed your requirements but for performance optimizations the XamDataGrid uses Lazy Object Creation when is set “LoadOnDemand”. The DataRecord and the Cell objects are thin wrappers around records and field values that are only created when they are asked for. However the DataRecord has Loaded and Unloaded events that you can use to make the validation. Also you can make the validation of the cell or even of the whole record at the moment end user change its value. For more information about this approach you can look at this references:
http://help.infragistics.com/NetAdvantage/WPF/2010.3/CLR4.0/?page=xamDataPresenter_Validate_Data_as_Your_End_Users_Edit_a_Cell.html
http://help.infragistics.com/NetAdvantage/WPF/2010.3/CLR4.0/?page=xamDataPresenter_Validating_Edited_Cell_Data_in_xamDataPresenter.html
If you need any further assistance on the matter please let me know.