Hi,
I have a 3-tier application (WCF, WPF, Prism, Unity and MVVM), I receive 1M models (for example Person) from the server which need to be shown in the XamDataGrid. My ViewModel exposes an ObservableCollection<PersonViewModel>, where PersonViewModel are simply wrapper around the model Person. Those wrapper are kind of big, and long to construct since the constructor parameters are mapped dynamically by unity framework. Would it be possible to lazy build those wrappers and ideally recycle them (basically virtualize them), so that only the shown records have a wrapper instance? It's require that the solution work with filtering, sorting and grouping!
Thanks,Dominik
Hello Dominik,
The XamDataGrid requires all of the records to be loaded to provide filtering, sorting and grouping.
If you have further questions, please let me know.
Thanks,
Hi Francis,
Thanks for your answer.
Still, do you have any suggestion to handle that kind of problem.
Regards,
Dominik
Hi Dominik,
I'm checking into this and will post here what I find out.
thanks for your reply. That's just the Information I needed.
I already tried sending Reset notifications, but did not know about the "DataSourceResetBehavior = DiscardExistingRecords" -requirement. After adding this Setting, my virtual DataSource is able to discard obsolete data.
At least almost all of it:
For some reason when in DiscardingExistingRecords-Mode the xamDataGrid requests the first DataItem on each Reset-Notification. This blocks the first chunk of data from ever getting deleted from the virtual DatatSource, because it seems to be needed all the time.
But as that only affects the lifespan of the first chunk of data, I think we can go by this solution at the moment. Until XamDataGrid has build-in support for virtual DataSources.
@Dominik:
Your idea is quite nice as well: Using Wrappers to reduce the size of the DataItems to nearly nothing. But: a million times nearly nothing still results in somthing big.
So that would probably not work for us.
Anyway, thanks for your suggestion
regards,
Hello [rmrop],
I have created a private support case to follow up with you and giving details about Feature Request FR13715 logged on your behalf.
Regarding your question about removing the dataitem; here is the reply I have from our Engineering team:
Once a Record has been created and the dataitem referenced, there is no way to discard the Record and its reference to the dataitem without sending a Reset notification from the datasource to which the grid is bound. (Note: in order for the Record to be discarded in this case the DataGrid’s DataSourceResetBehavior property must be set to DiscardExistingRecords).
Thanks
Hello rmrop,
I just want to be sure the recipient of that last post was really Francis, one of your team member, since there's no reply for this post for almost 2 week.
Anyway, just to brainstorm some ideas. There could be a new class
public class VirtualObservableCollection<WrapperViewModelType, ModelType> where WrapperViewModelType : IWrapperViewModel<ModelType>
with constructors taking first parameter
Func<WrapperViewModelType> createNewWrapperViewModel
and interface
public interface IWrapperViewModel<T> { void InitializeModel(T model); void UninitializedModel(); }
I believe there's no problem in keeping a collection of dataitem, the only important thing is to call InitializeModel and UninitializedModel before and after using them and showing them.
Not sure if it help or not, feel free to ignore this reply, this model might not be relevant depending on your internal model.
Hello Francis,
I would like to second this feature request, but couldn't figure out how to do so.
Meanwhile:
Francis"] we don’t ‘discard’ the dataitem when the record goes out of view.
we don’t ‘discard’ the dataitem when the record goes out of view.
Is there a way to discard the dataitem (i.e. the reference the record is holding) by hand?
Thanks, I really appreciate the effort that you and Infragistic team do to awnser our business needs.
On a side note, if possible, it would be appreciated if the solution for that problem could support the MVVM pattern.
Thanks, continue the good job,