INotifyPropertyChanged not triggering a Grid update

6 posts, 0 answers
  1. Luke Daugherty
    Luke Daugherty avatar
    19 posts
    Member since:
    Jun 2011

    Posted 31 May 2013 Link to this post

    We are using a DataRow object that implements DynamicObject and INotifyPropertyChanged to bind data to Grid. Using the latest builds (I have tried up to the 5/27 hotfix) if we add a new column or change the value of one of the DataRow fields at runtime, which triggers a PropertyChangedEventHandler to fire, the grid is not reflecting the value change.  I don't even see a call being made to DataRow to get retrieve the new value.

    If I revert to the last version we were using (2012 Q3), with no code changes, the functionality works again. Is this a known issue? Is there a fix for this?

        public class DataRow : DynamicObject, INotifyPropertyChanged
        {
            private IDictionary<string, object> columns;

            public DataRow()
            {
                columns = new Dictionary<string, object>();
            }

            public DataRow(IDictionary<string, object> source)
            {
                columns = source;
            }
            
            public override IEnumerable<string> GetDynamicMemberNames()
            {
                return columns.Keys;
            }

            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;
            }

            public void RemoveColumn(string columnName)
            {
                columns.Remove(columnName);
            }

            public object this[string columnName]
            {
                get
                {
                    if (columns.ContainsKey(columnName))
                    {
                        return columns[columnName];
                    }

                    return null;
                }
                set
                {
                    if (!columns.ContainsKey(columnName))
                    {
                        columns.Add(columnName, value);

                        OnPropertyChanged(columnName);
                    }
                    else
                    {
                        if (columns[columnName] != value)
                        {
                            columns[columnName] = value;

                            OnPropertyChanged(columnName);
                        }
                    }
                }
            }

            public DataRow Clone()
            {
                return new DataRow(new Dictionary<string, object>(this.columns));
            }

            private void OnPropertyChanged(string propertyName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }

            #region INotifyPropertyChanged Members

            public event PropertyChangedEventHandler PropertyChanged;

            #endregion
        }
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 05 Jun 2013 Link to this post

    Hello Luke,

     We will need some more time to track the cause of this behavior. I will contact you as soon as we are ready. Please, excuse me for this delay.

    Regards,
    Ivan Ivanov
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Luke Daugherty
    Luke Daugherty avatar
    19 posts
    Member since:
    Jun 2011

    Posted 05 Jun 2013 Link to this post

    OK. I also submitted a support ticket (701255) and attached sample code. Thanks.

  5. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 06 Jun 2013 Link to this post

    Hello,

     Thank you for to the test project. I have just posted a reply to the other thread of yours.

    Regards,
    Ivan Ivanov
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Ubuntu
    Ubuntu avatar
    89 posts
    Member since:
    Jul 2012

    Posted 25 Aug 2013 Link to this post

    Dear All,

        I appreciate if you could post the fix here so we can use as well.

    Best regards
  7. Luke Daugherty
    Luke Daugherty avatar
    19 posts
    Member since:
    Jun 2011

    Posted 26 Aug 2013 Link to this post

    The fix was to set the value prior to adding the ColumnDescriptor. Something like:

    row[columnDescriptor.ColumnName] = modelChangedData.PropertyChange.NewValue;
            EdgeColumns.Add(columnDescriptor);

    Prior to this defect, these lines were swapped.

    Luke

Back to Top
DevCraft banner