C1DataGrid Master/Detail lazy loading

Posted by: elogsdon on 15 August 2018, 11:09 am EST

  • Posted 15 August 2018, 11:09 am EST

    I am looking to replace my treeview control because of performance issues. So far, I have had good luck with my experimentation using the c1DataGrid master/detail. I do have a need to do lazy loading for performance. When using the Treeview in the IsExpanded property on the master I would load the details if they weren't loaded. On the c1DataGridRow, I don't see an IsExpanded or equivalent. Is there an event or property I could use to perform lazy loading?

    Thanks, Eric.
  • Replied 16 August 2018, 6:13 am EST

    Hi Eric,

    Thank you for showing interest in using ComponentOne.
    For your requirement: lazy loading, there are few things I would suggest you:
    1. Use C1DataSource in Virtual mode along with C1DataGrid. You can refer our product sample installed at location\Documents\ComponentOne Samples\WPF\C1.WPF.DataSource\CS\TutorialsWPF-C1DataGrid for this.
    2. Use C1DataGird in hierarchical way [nested grid] to get TreeView like output. And for lazy loading, check whether the master row's DetailsVisibility property returns true/false. If it is false, then that row is not in current view and hence, we can avoid loading its children.
    Note: You can use this in conjunction with row's DetailsPresenter.
    • If master row's DetailsPresenter is null, then that row has never been loaded/came in view.

    • If master row's DetailsPresenter is not null but its DetailsVisibility is Collapsed, then we can prevent its children from loading.

    • If master row's DetailsPresenter is not null and its DetailsVisibility is Visible, then only load the children for this master row.

    Also in addition to above, C1DataGrid offers a property by the name ScrollMode. Setting this property to Deferred, the page would scroll once the user releases the scrollbar. This should help you in improving your application's performance.

    Let me know, if you need any help further.

  • Replied 16 August 2018, 8:56 am EST

    Thank you. I will look at the sample and let you know if I have any more questions on this topic.

  • Replied 16 August 2018, 9:53 am EST

    It appears that C1DataSource is for Entity Framework. This project is not using Entity Framework, so this won't work for me.

    Is there an event or property I can utilize when the Master is expanded to show the Details? when using a Treeview, I used the IsExpanded property to load the children into an ObservableCollection for binding if IsExpanded was being set to true.

  • Marked as Answer

    Replied 17 August 2018, 12:01 am EST

    Hello Eric,

    Thank you for informing that your application is not using Entity Framework. However, did you try using our second suggestion?
    Also, in addition to the above. each row has DetailsVisibilityChanged event which fires when the visibility of children rows change i.e., when end-user either expands/collapses a row of the master grid. I understand this is the event that you need.
    Also, refer to attached sample for implementation.
    If this is not what you need, could you kindly share your application or modify the attached sample and share back so that we can make changes in your application accordingly.

  • Replied 20 August 2018, 3:10 pm EST

    I thought 1 & 2 were part of the same solution, my error. I'll look into it.
  • Replied 20 August 2018, 11:48 pm EST

    Hello Eric,

    Its okay! You may take your time to test the suggestions at your end and thereafter share your observations with us.
    We will be waiting to hear from you.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels