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

INotifyPropertyChanged not triggering a Grid update

5 Answers 87 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Luke Daugherty
Top achievements
Rank 1
Luke Daugherty asked on 31 May 2013, 04:23 PM
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
    }

5 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 05 Jun 2013, 04:11 PM
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.

0
Luke Daugherty
Top achievements
Rank 1
answered on 05 Jun 2013, 04:14 PM
OK. I also submitted a support ticket (701255) and attached sample code. Thanks.

0
Ivan Ivanov
Telerik team
answered on 06 Jun 2013, 02:47 PM
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.

0
Ubuntu
Top achievements
Rank 1
answered on 25 Aug 2013, 06:14 PM
Dear All,

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

Best regards
0
Luke Daugherty
Top achievements
Rank 1
answered on 26 Aug 2013, 02:10 PM
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

Tags
GridView
Asked by
Luke Daugherty
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Luke Daugherty
Top achievements
Rank 1
Ubuntu
Top achievements
Rank 1
Share this question
or