We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

sfDataGrid data virtualization with Just-In-Time Data Loading

Thread ID:

Created:

Updated:

Platform:

Replies:

146948 Aug 26,2019 06:11 PM UTC Aug 28,2019 04:57 PM UTC WinForms 3
loading
Tags: SfDataGrid
Richard
Asked On August 26, 2019 06:11 PM UTC

I am new to Syncfusion and looking to get a sfDataGrid coded that has data virtualization and just-in-time data loading similar to discussion in MS article How to: Implement Virtual Mode with Just-In-Time Data Loading in the Windows Forms DataGridView Control

After I code 

sfDataGrid1.EnableDataVirtualization = true;

I'm lost on where to proceed next.

  • How do I know when a new 'page' of data is needed ?

The DataTable I am using for each 'page' of just-in-time data is constructed from a MongoDB find() against arbitrary collections.  
Some of the collections have 100K documents and a few hundred fields.
The page 'datatables' would probably also be cached locally to some extent.

    var pageDocuments =
      Database
      .GetCollection<BsonDocument>(collectionName)
      .Find(filter)
      .Skip(pageOffset)
      .Limit(pageSize)
      .ToList()
      ;

    var pageDataTable = new DataTable();

    foreach (BsonDocument doc in pageDocuments) {
      DataRow row = pageDataTable.NewRow();
      foreach (BsonElement in doc.Elements) {
                            switch (element.Value.BsonType)
                            {
                                case BsonType.Boolean:
                                    if (!pageDataTable.Columns.Contains(element.Name))
                                    {
                                        pageDataTable.Columns.Add(new DataColumn(element.Name, Type.GetType("System.Double")));
                                    }
                                    row[element.Name] = element.Value == 0 ? false : true;
                                    break;
                                case BsonType.Int32:
                                    if (!page.Columns.Contains(element.Name))
                                    {
                                        pageDataTable.Columns.Add(new DataColumn(element.Name, Type.GetType("System.Int32")));
                                    }
                                    row[element.Name] = element.Value.AsInt32;
                                    break;
                                case BsonType.Double:
                                    if (!pageDataTable.Columns.Contains(element.Name))
                                    {
                                        pageDataTable.Columns.Add(new DataColumn(element.Name, Type.GetType("System.Double")));
                                    }
                                    row[element.Name] = Math.Round(element.Value.AsDouble, 6);
                                    break;
                                case BsonType.DateTime:
                                    if (!pageDataTable.Columns.Contains(element.Name))
                                    {
                                        pageDataTable.Columns.Add(new DataColumn(element.Name, Type.GetType("System.DateTime")));
                                    }
                                    row[element.Name] = element.Value;
                                    break;                
      }
    }
  
  

    



Susmitha Sundar [Syncfusion]
Replied On August 27, 2019 05:54 PM UTC

Hi Richard, 
 
Thank you for using Syncfusion support. 
 
Based on the provided information, we suspect that you need to enable DataVirtualization for SfDataGrid. If so, please refer the following sample, 
 
 
If we misunderstood anything, please provide more details about your requirement. It will be helpful for us to investigate further. 
 
Regards, 
Susmitha S 
 


Richard
Replied On August 27, 2019 09:16 PM UTC

Hi Susmitha:

Thanks for the link to the demo projects.

In the demo for sfDataGrid Data Virtualization the grid operates very fast as expected when sfDataGrid1.EnableDataVirtualization=true.  I did notice the grid data source assignment

sfDataGrid1.DataSource = collection.OrdersListDetails;

I am guessing that the virtualization sets up all the hidden internal activity (cell query events etc) necessary for the grid to access the fully populated OrdersListDetails (which is a List of count OrderInfo instances.)

In sfDataGrid there does not seem to be a path for doing page based virtualization using queries against a remote data service.

Q: Is there a accessible event in sfDataGrid like GridControl's QueryCellInfo event ?

Q: Do I have to forgo the sfDataGrid and fall back to using GridControl where I would have to code the event handlers QueryRowCount, QueryColCount, QueryCellInfo,to make the Grid operate ?

I think that within the QueryCellInfo handler I would be able to know if another 'page' of data has to be queried from the remote database and cached for use in future callbacks to QueryCellInfo


Susmitha Sundar [Syncfusion]
Replied On August 28, 2019 04:57 PM UTC

Hi Richard, 
 
Thank you for your update. 
 
Please find the details about different Grids, 
 
 
Query 1: In sfDataGrid there does not seem to be a path for doing page based virtualization using queries against a remote data service 
 
We have paging support for SfDatagrid. You can load the data by OnDemandLoading. But you did not load the DataTable directly to paging datasource. You need to change the datatable to dynamic object and set this to datasource of Pager. It will loading data by page manner. 
 
Please refer the below UG link, 
 
Query 2: Is there a accessible event in sfDataGrid like GridControl's QueryCellInfo event ? 
 
SfDataGrid does not have QueryCellInfo event. In SfDataGrid row and column count value updated only in Initial loading. We did not update row and column count at run time. 
 
Query 3: Do I have to forgo the sfDataGrid and fall back to using GridControl where I would have to code the event handlersQueryRowCount, QueryColCount, QueryCellInfo,to make the Grid operate ? 
 
Please refer the user guide documentation and for GridControl mentioned events, 
Please contact us for further details. 
 
Regards, 
Susmitha S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon