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
630
Cell level format
posted

Hi

Is there a cell level property using which i can apply formats to a value for a particular cell?

I have grid(dynamic grid using ultradatasource) such that there are predefined formats(e.g. percentage,currency etc) to be applied to values for some cells within a column.

In the forums i can find ways to apply format for a complete column but that is not useful in my case.

Normal 0 false false false EN-US X-NONE X-NONE

 

TYPE

VALUE

a

<dollar>

b

<percentage>

 

Parents
No Data
Reply
  • 69832
    Offline posted

    The best way to solve this problem is to use a DefaultEditorOwner when you create the editor that you assign to the UltraGridColumn.Editor property. This class derives from the class that we use to abstract out the communication layer between the editor and the grid. In your case you would derive a class from DefaultEditorOwner, override the GetFormat method, and pass an instance this derived class into the constructor of the editor you assign to the UltraGridColumn.Editor property.

    The signature of the GetFormat method (like most of the virtual methods exposed by this class) contains an 'ownerContext' parameter; this is either the UltraGridCell or a CellUIElement, and if I remember, can also be an UltraGridRow as well, although you can ignore that case and just call the base class implementation. Once you get a context of a cell, you decide what format you want to apply, then assign that format to the out parameter of the same name. In this manner, you can apply a different format to each cell in that column dynamically.

Children