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)...
Still looking for answer to this issue. I've reviewed several links for XamDataGrid performance optimization and I've been tirelessly running my VS debugger trying to find an exposed property that might tell me when a record has yet to be initialized. There has to be a way to know when records have been previously loaded or not. Does anyone have an answer for this?
Hello,
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.
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.
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.