Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 99250

How to use GridView with VirtualQueryableCollectionView for growing datasource?

$
0
0

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:

publicpartialclassMainWindow : Window
    {
        privateconststring_connStringTemplate = "metadata=res://*/IomapMonitorModel.csdl|res://*/IomapMonitorModel.ssdl|res://*/IomapMonitorModel.msl;provider=System.Data.SQLite.EF6;provider connection string='data source={0}'";
        privateconststring_dbPath = "t4.iop";
        privateVirtualQueryableCollectionView _cv;
        privateIomapMonitorEntities _context;
        privateint_tick = 0;
        publicMainWindow()
        {
            InitializeComponent();
 
            var _connStr = String.Format(_connStringTemplate, _dbPath);
            _context = newIomapMonitorEntities(_connStr);
            var query = _context.RawRecords.OrderBy(o => o.Id);
 
            _cv = newVirtualQueryableCollectionView(query) { LoadSize = 100 };
 
            DataContext = _cv;
 
            StartRefresh();
        }
 
        privatevoidStartRefresh()
        {
            var timer = newTimer(1000);
            timer.Elapsed += newElapsedEventHandler((obj, e) =>
            {
                if(_cv != null)
                {
                    if(_tick < 20)
                    {
                        _context.RawRecords.Add(newRawRecord()
                        {
                            CardId = 0,
                            CardType = "422",
                            ChannelId = 0,
                            Direction = "RX",
                            ProtocolType = "422",
                            Tick = _tick++,
                            TimeStamp = 11111,
                            Data = newbyte[] { 9, 8, 7 },
                            Miscellaneous = null
                        });
                        _context.SaveChanges();
                    }
                    _cv.Refresh();
                }
            });
            timer.AutoReset = true;
            timer.Enabled = true;
        }
    }

 

 


Viewing all articles
Browse latest Browse all 99250

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>