This is a migrated thread and some comments may be shown as answers.

How to use GridView with VirtualQueryableCollectionView for growing datasource?

6 Answers 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
rick
Top achievements
Rank 1
rick asked on 12 Sep 2016, 01:57 AM

I'm trying to use RadGridView with VirtualQueryableCollectionView  to display data from database.

The data is very large and it's growing in real time, let's say there are more than 25 rows will be added into database every second. And I want to refresh RadGridView to show real time data.

 

How can I do that? Is there any example?

 

Thanks very much!

 

 

6 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 12 Sep 2016, 12:42 PM
Hello Rick,

We have a couple of demos on Data Virtualization in our WPF demos application, however, the source remains unchanged. 
Please check the following forum thread where a similar topic was discussed - How to update items in a RadGridView with VirtualQueryableCollectionView as the scenario seems similar to yours.

Regards,
Stefan Nenchev
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
rick
Top achievements
Rank 1
answered on 13 Sep 2016, 03:53 AM

Stefan, thanks for your quick reply.

I have checked the linked thread you mentioned. The first question in that thread is similar as mine. However, I don't find a final solution for it in that thread.

The solution Vlad given in that thread, use a timer to add a new item to VirtualQueryableCollectionView every second seems not applicable for my case, since the database is updated by other user via another application. And I don't know when and how many rows will be added. So I wonder if there is a way to simply "refresh" the underlying data source (the db query) every second manually, and gridview will automatically fetch the new data? 

0
Stefan Nenchev
Telerik team
answered on 14 Sep 2016, 11:44 AM
Hello Rick,

My colleague has suggested a possible approach in order to not reset the whole collection and respectively the RadGridView. However, you can invoke the Refresh method of the VirtualQueryableCollectionView which will recreate the view.

Regards,
Stefan Nenchev
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
rick
Top achievements
Rank 1
answered on 18 Sep 2016, 12:22 PM

Thanks, Stefan! I have tried using the Refresh method, but I can't make it working. As shown in the screenshot, the gridview will not show the latest data in the SQLite database. You can see there are only 9 rows in the gridview which does not match the records number in SQLite database.

My code snippet:

public partial class MainWindow : Window
    {
        private const string _connStringTemplate = "metadata=res://*/IomapMonitorModel.csdl|res://*/IomapMonitorModel.ssdl|res://*/IomapMonitorModel.msl;provider=System.Data.SQLite.EF6;provider connection string='data source={0}'";
        private const string _dbPath = "t4.iop";
        private VirtualQueryableCollectionView _cv;
        private IomapMonitorEntities _context;
        private int _tick = 0;
        public MainWindow()
        {
            InitializeComponent();
 
            var _connStr = String.Format(_connStringTemplate, _dbPath);
            _context = new IomapMonitorEntities(_connStr);
            var query = _context.RawRecords.OrderBy(o => o.Id);
 
            _cv = new VirtualQueryableCollectionView(query) { LoadSize = 100 };
 
            DataContext = _cv;
 
            StartRefresh();
        }
 
        private void StartRefresh()
        {
            var timer = new Timer(1000);
            timer.Elapsed += new ElapsedEventHandler((obj, e) =>
            {
                if (_cv != null)
                {
                    if (_tick < 20)
                    {
                        _context.RawRecords.Add(new RawRecord()
                        {
                            CardId = 0,
                            CardType = "422",
                            ChannelId = 0,
                            Direction = "RX",
                            ProtocolType = "422",
                            Tick = _tick++,
                            TimeStamp = 11111,
                            Data = new byte[] { 9, 8, 7 },
                            Miscellaneous = null
                        });
                        _context.SaveChanges();
                    }
                    _cv.Refresh();
                }
            });
            timer.AutoReset = true;
            timer.Enabled = true;
        }
    }

 

 

0
rick
Top achievements
Rank 1
answered on 18 Sep 2016, 12:30 PM
I'm using UI for WPF Q3 2015\Binaries\WPF40\Telerik.Windows.Controls.GridView.dll
0
Stefan Nenchev
Telerik team
answered on 21 Sep 2016, 10:48 AM
Hello Rick,

Would it be possible to provide us with a sample project which we can review from our side and investigate in details so we can try to suggest a possible solution? As uploading projects in the forum thread is not possible, the best approach would be to create a ticket and we can proceed the discussion there.

Regards,
Stefan Nenchev
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
rick
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
rick
Top achievements
Rank 1
rick
Top achievements
Rank 1
Share this question
or