Dynamic Compute Column




  • Dapfor Team


    This is a really easy with the .Net Grid and can be done in 2 lines of code. The main idea is to join properties of different objects. You’ve already the MyData class which implements the INotifyPropertyChanged interface. Very good! We should just add a field UnboundValueAccessor to this class and corresponding get-property. Let’s call it DynamicFields. Then you have to decorate this property with the CompositeFieldAttribute. UnboundValueAccessor represents a kind of dictionary with variable number of fields. Look at the following example:


    class MyData : INotifyPropertyChanged
        private readonly UnboundValueAccessor _dynamicFields = new UnboundValueAccessor();

        public int Price
            get { return _Price; }
                _Price = value; Notify("Price");
                _dynamicFields["Field1"].Value = _Price*_Qty;

        public UnboundValueAccessor DynamicFields
            get { return _dynamicFields; }

    Objects of this class are able to notify the grid each time when a setter is called. Finally, you should add columns with field identifiers that match to fields of the UnboundValueAccessor. A good practice will be to set an appropriate formats in that columns. Please find an attached example, demonstrating this approach.

    Best regards,


  • sassendran

    This doesn't works for us, as we need the formula for the dynamic column needs to given dynamically by the end user. So can you suggest us how .NET grid can be used for this facility.

Please sign in to leave a comment.

Powered by Zendesk