Create Data Virtualization for flexgrid

Posted by: levanduyet on 27 April 2024, 2:16 am EST

  • Posted 27 April 2024, 2:16 am EST

    Hi,

    I want to create a data virtualization for flexgrid. Data source is a Table from Sql server.

    I read the introduction from this link:

    https://developer.mescius.com/componentone/docs/win/online-flexgrid/data-virtualization.html

    I have a connection string from App.Config

    string connectionString = ConfigurationManager.ConnectionStrings["ConnectToSqlServer"].ConnectionString;

    So, which c1 component that I should use in this case.

    Thanks,

    Duyet Le

  • Posted 27 April 2024, 4:39 am EST

    HI,

    1, I have tried the following code, it’s okay but it take long time at

    await dataCollection.LoadMoreItemsAsync();

    How to improve this.

    string conString = ConfigurationManager.ConnectionStrings["Testing"].ConnectionString;
    SqlConnection conn = new SqlConnection(conString);
    dataCollection = new C1AdoNetCursorDataCollection<Item>(conn,"Items");
    //It take time here
    await dataCollection.LoadMoreItemsAsync();
    fgItems.DataSource = new C1DataCollectionBindingList(dataCollection);

    My table is about 86,000 lines.

    If I load directly, it will be faster than above code.

    Thanks,

    Duyet Le

  • Posted 28 April 2024, 10:51 pm EST

    Hi Duyet,

    Thank you for providing your sample code.

    We tested your code by connecting to our local MSSQL server and loading data from a table containing 1,000,000 rows. When the dataCollection.LoadMoreItemsAsync() method is called for the first time, it loads 50 rows by default, and takes around 500-600 milliseconds on our end. Please refer to the attached screenshot showing the same (ref. DataLoadingTime.zip)

    Afterwards, when more data is loaded using dataCollection.LoadMoreItemsAsync() method in the FlexGrid.AfterScroll event, it loads instantly without any noticeable delay.

    For further investigation, could you please share the following details:

    1. Some dummy data that shows the issue on your end.
    2. A screenshot showing the loading time on your end (you can use the FlexGrid.AfterDataRefresh event to check this).
    3. The version of C1FlexGrid and C1DataCollections you are using.
    4. Your environment details like CPU, RAM and OS.

    Thanks, and Best Regards,

    Kartik

  • Posted 29 April 2024, 6:46 pm EST - Updated 29 April 2024, 6:52 pm EST

    HI Kartik,

    1, You can download from the link:

    https://drive.google.com/file/d/1BSY_6ZplCdCvZWFG0YB7poTIUFuAOSRq/view?usp=sharing

    2, See attached photo

    3, C1.Win.C1FlexGrid.4.8; version: v4.0.30319

    C1.DataCollections; version: v4.0.30319

    4, My environment:

    _ Windows 11 Pro, version 22H2

    _ 12th Gen Intel(R) Core™ i7-12850HX 2.10 GHz

    _ RAM: 32MB

    _ 64-bit operating system

  • Posted 30 April 2024, 10:25 pm EST

    Hi Duyet,

    Thank you for providing all the details.

    We imported your dummy data in our local MSSQL server and tested loading that data virtually in C1FlexGrid using your code. It took only 400-450 milliseconds of time to load the first set of records each time we tested. Please see the attached video showing the code we are using and the behavior we observe - Virtualization Behavior.zip

    If you have a different implementation than this, could you please provide a stripped-down version of your project that reproduces this behavior, so we can investigate further on this?

    Note: The version you provided in point (3) of your response is the .NET runtime version and not the version of C1 controls. To check the version of C1 controls,

    1. Right click on the C1 DLL reference,
    2. Click properties, and
    3. Observe the Version field in the property window.

    Thanks, and Best Regards,

    Kartik

  • Posted 2 May 2024, 1:18 am EST - Updated 2 May 2024, 1:23 am EST

    Hi Kartik,

    Time is still high.

    Could you pls share your testing code project.

    The C1flexgrid that I have checked the **Version **as attached file.

    Thanks,

    Duyet Le

  • Posted 2 May 2024, 4:53 am EST

    Hi Duyet,

    Here is the sample project we tested by importing your dummy data in an MSSQL server. Please update the “Connection String” and “Table Name” in the sample project as per your credentials.

    FlexGridVirtualization.zip

    If the issue persists, please update this project to reproduce the issue, so we can investigate further.

    Thanks, and Best Regards,

    Kartik

  • Posted 2 May 2024, 1:59 pm EST

    Hi Kartik,

    The time is better now. Look like due to the Item class that I follow C1 sample on the web.

    public class Item: INotifyPropertyChanged, IEditableObject
        {
            #region Fields
            private int _isSalesItem;//0 and 1
    		private string _itemCode, _description_1, _packageDescription, _warehouse,
    			_userField_01, _userField_02, _userField_03, _userField_04, _userField_05,
    			_userField_06, _userField_07, _userField_08, _searchCode;
    		private char _condition;
    		private double _costPriceStandard, _salesPackagePrice;
            #endregion
            #region Properties
            
            public string ItemCode
            {
                get => _itemCode;
                set
                {
                    if (_itemCode != value)
                    {
                        _itemCode = value;
                        OnPropertyChanged();
                    }
                }
            }
            public string Description_1
            {
                get => _description_1;
                set
                {
                    if (_description_1 != value)
                    {
                        _description_1 = value;
                        OnPropertyChanged();
                    }
                }
            }
            public string PackageDescription
            {
                get => _packageDescription;
                set
                {
                    if (_packageDescription != value)
                    {
                        _packageDescription = value;
                        OnPropertyChanged();
                    }
                }
            }
            public int IsSalesItem
            {
                get => _isSalesItem;
                set
                {
                    if (_isSalesItem != value)
                    {
                        _isSalesItem = value;
                        OnPropertyChanged();
                    }
                }
            }
            public double CostPriceStandard
            {
                get => _costPriceStandard;
                set
                {
                    if (_costPriceStandard != value)
                    {
                        _costPriceStandard = value;
                        OnPropertyChanged();
                    }
                }
            }
            public double SalesPackagePrice
            {
                get => _salesPackagePrice;
                set
                {
                    if (_salesPackagePrice != value)
                    {
                        _salesPackagePrice = value;
                        OnPropertyChanged();
                    }
                }
            }
            public char Condition
            {
                get => _condition;
                set
                {
                    if (_condition != value)
                    {
                        _condition = value;
                        OnPropertyChanged();
                    }
                }
            }
            public string Warehouse
            {
                get => _warehouse;
                set
                {
                    if (_warehouse != value)
                    {
                        _warehouse = value;
                        OnPropertyChanged();
                    }
                }
            }
            public string SearchCode
            {
                get => _searchCode;
                set
                {
                    if (_searchCode != value)
                    {
                        _searchCode = value;
                        OnPropertyChanged();
                    }
                }
            }
            public string UserField_01
            {
                get => _userField_01;
                set
                {
                    if (_userField_01 != value)
                    {
                        _userField_01 = value;
                        OnPropertyChanged();
                    }
                }
            }
            public string UserField_02
            {
                get => _userField_02;
                set
                {
                    if (_userField_02 != value)
                    {
                        _userField_02 = value;
                        OnPropertyChanged();
                    }
                }
            }
            public string UserField_03
            {
                get => _userField_03;
                set
                {
                    if (_userField_03 != value)
                    {
                        _userField_03 = value;
                        OnPropertyChanged();
                    }
                }
            }
            public string UserField_04
            {
                get => _userField_04;
                set
                {
                    if (_userField_04 != value)
                    {
                        _userField_04 = value;
                        OnPropertyChanged();
                    }
                }
            }
            public string UserField_05
            {
                get => _userField_05;
                set
                {
                    if (_userField_05 != value)
                    {
                        _userField_05 = value;
                        OnPropertyChanged();
                    }
                }
            }
            public string UserField_06
            {
                get => _userField_06;
                set
                {
                    if (_userField_06 != value)
                    {
                        _userField_06 = value;
                        OnPropertyChanged();
                    }
                }
            }
            public string UserField_07
            {
                get => _userField_07;
                set
                {
                    if (_userField_07 != value)
                    {
                        _userField_07 = value;
                        OnPropertyChanged();
                    }
                }
            }
            public string UserField_08
            {
                get => _userField_08;
                set
                {
                    if (_userField_08 != value)
                    {
                        _userField_08 = value;
                        OnPropertyChanged();
                    }
                }
            }
            
            #endregion
            #region INotifyPropertyChanged Members
            public event PropertyChangedEventHandler PropertyChanged;
    
            private void OnPropertyChanged([CallerMemberName] string propertyName = "")
            {
                OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
            }
    
            protected void OnPropertyChanged(PropertyChangedEventArgs e)
            {
                PropertyChanged?.Invoke(this, e);
    
            }
            #endregion
            #region IEditableObject Members
            private Item _clone;
    
            public void BeginEdit()
            {
                _clone = (Item)MemberwiseClone();
            }
    
            public void CancelEdit()
            {
                if (_clone != null)
                {
                    foreach (var p in GetType().GetRuntimeProperties())
                    {
                        if (p.CanRead && p.CanWrite)
                        {
                            p.SetValue(this, p.GetValue(_clone, null), null);
                        }
                    }
                }
            }
    
            public void EndEdit()
            {
                _clone = null;
            }
            #endregion
        }

    Thanks,

    Duyet Le

  • Posted 2 May 2024, 2:00 pm EST

    Hi,

    The time is as attached photo.

    Duyet Le

  • Posted 2 May 2024, 2:06 pm EST - Updated 2 May 2024, 2:11 pm EST

  • Posted 2 May 2024, 9:29 pm EST

    Hi Duyet,

    Thank you for sharing the screenshot. It seems like the issue is now resolved on your end. If you face any further issues regarding this, please let us know.

    Best Regards,

    Kartik

  • Posted 4 May 2024, 9:18 am EST

    Hi Kartik,

    It still took 5203. How can I make it load first 100 row only and update on the c1flexgrid.

    Thanks,

    Duyet Le

  • Posted 5 May 2024, 10:33 pm EST

    Hi Duyet,

    By default, the PageSize property of the C1AdoNetCursorDataCollection is set to 50, meaning it loads a total of 50 new records each time the LoadMoreItemsAsync method is called. If you want to change it, you can pass your custom value to the pageSize paramater of the constructor as follows:

    var dataCollection = new C1AdoNetCursorDataCollection<DummyData>(conn, "Dummy_Data", new List<string>() { "ItemCode", "ItemDes", "Status", "Sales", "Buy", "Make", "Stock" }, 100);

    As for taking 5203ms time on your end, we could not reproduce the issue. If the issue persists, please update the attached sample project with your implementation to reproduce the issue, so we can investigate further.

    Attachment: FlexGridVirtualization_PageSize.zip

    Thanks, and Best Regards,

    Kartik

Need extra support?

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

Learn More

Forum Channels