Data virtualization empty grid

2 posts, 0 answers
  1. Omer Javed
    Omer Javed avatar
    2 posts
    Member since:
    Aug 2009

    Posted 26 Jul 2013 Link to this post

    Hello,

    I am using VirtualQueryableCollectionView to implement Data Virtualization. Upon receiving data in completed event of a service call i am calling the Load method of the view. However it doesn't populate the view with received items and the grid remains empty. Here is the piece of code which tries to load items into view.

    public void OnLookupCompleted(object sender, LookupRecordsCompletedEventArgs e)
            {
    ...
    DynamicItems.Load(0, PrepareDynamicRows(e.Response.LookupRows));
     ...
    }
     
    public ObservableCollection<dynamic> PrepareDynamicRows(List<LookupRow> lookupRows)
            {
                ObservableCollection<dynamic> dynamicRows = new ObservableCollection<dynamic>();
                lookupRows.ForEach(x => dynamicRows.Add(new DynamicRow(x)));
                return dynamicRows;
            }

    Here is the implementation of DynamicRow class which might help.

    public class DynamicRow : DynamicObject, INotifyPropertyChanged
        {
            LookupRow _lookupRow;
     
            public DynamicRow()
            {
                _lookupRow = new LookupRow();
            }
     
            public DynamicRow(LookupRow lookupRow)
            {
                _lookupRow = lookupRow;
            }
     
            public override IEnumerable<string> GetDynamicMemberNames()
            {
                // output the avaiable names based on the dictionary of colum data, plus the Id field
                List<string> names = new List<string>();
                names.Add("Id");
                names.AddRange(_lookupRow.ColumnData.Keys);
     
                return names;
            }
     
            public override bool TryGetMember(GetMemberBinder binder, out object result)
            {
                result = this[binder.Name];
                return true;
            }
     
            public override bool TrySetMember(SetMemberBinder binder, object value)
            {
                this[binder.Name] = value;
                return true;
            }
     
            /// <summary>
            /// Provides an indexer to retrieve either the Id or a value from the dictionary
            /// </summary>
            /// <param name="columnName"></param>
            /// <returns></returns>
            public object this[string columnName]
            {
                get
                {
                    if (columnName == "Id")
                    {
                        return _lookupRow.RelatedEntity.Id;
                    }
     
                    if (_lookupRow.ColumnData.ContainsKey(columnName))
                    {
                        return _lookupRow.ColumnData[columnName];
                    }
     
                    return null;
                }
                set
                {
                    if (columnName == "Id")
                    {
                        _lookupRow.RelatedEntity.Id = value as string;
                        return;
                    }
     
                    if (!_lookupRow.ColumnData.ContainsKey(columnName))
                    {
                        _lookupRow.ColumnData.Add(columnName, value);
     
                        OnPropertyChanged(columnName);
                    }
                    else
                    {
                        if (_lookupRow.ColumnData[columnName] != value)
                        {
                            _lookupRow.ColumnData[columnName] = value;
     
                            OnPropertyChanged(columnName);
                        }
                    }
                }
            }
     
            public LookupRow LookupRow
            {
                get { return _lookupRow; }
                set { _lookupRow = value; }
            }
     
            private void OnPropertyChanged(string propertyName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }
     
            #region INotifyPropertyChanged Members
     
            public event PropertyChangedEventHandler PropertyChanged;
     
            #endregion
        }

    Please can you guide what may be missing to successfully load items into view. Thanks.


    Regards,
    Omer Javed
  2. Yoan
    Admin
    Yoan avatar
    1159 posts

    Posted 31 Jul 2013 Link to this post

    Hi,

    I would suggest you to check our online documentation for more information on using Data Virtualization. Moreover, you can check our online demo here.

    Regards,
    Yoan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top