Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
310
How do I modify the column names when binding a collection of DTO's to UltraGrid?
posted

I have a collection of objects of a data transfer object class which I put data into. When I bind this collection to an UltraGrid, it works as expected and makes the property names of the class the column names. I would now like to alter the column names to be a little more user friendly.

 public class AllocationDTO
    {
        public int DeliveryID { get; set; }
        public string Ctpy { get; set; }
        public int NominationRank { get; set; }
        public double BAV { get; set; }
        public double AllocationQuantity { get; set; }
    }

As an example I would like the "DeliveryID" column to be "Delivery ID". What should I do to make this work?

In my InitializeLayout of the grid I've tried an equivalent of the following:

e.Layout.Bands[0].Columns["DeliveryID"].Header.Caption = "Delivery ID";

This works but it leaves me using a literal string, which coincides with my property name. I think I would like to use an attribute in the DTO, if one works, unless there is something even simpler I can do in the InitializeLayout. What are my options really?

 

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi,

    The grid doesn't pick up any attributes automatically. But you could, of course, add whatever attribute you like to each property, even a custom attribute if you want, and then get that attribute in code and set the Caption on the column.

     

Children
No Data