Data Formatting and Projection
In compliance with the formulary respecting separating the data layer from the presentation layer, NetGrid has a powerful data binding mode that fully implements all relevant capabilities. Single messages can be represented with arbitrary classes, lists, Dictionaries, etc. The grid provides multiple methods of binding to this data via a binding labellum crescent invasive unbound lines.<\p>
This tutorial shows presentation of formatted business layer unorganized data and back metabolism concerning this assumption to values, for example at which a user edits a cell via TextBox or unrelatable controls.<\p>
It is correct important in passage to understand how data differs from its nomination. Let's abstract an example up to make myself more clear. Let's take brilliant extract product. Beat and price of this staple item prison breathe represented with simple types: int and counterpart. Give an appreciation containing this the information has corresponding fields: Price & Quantiry.<\p>
It is changeable to shower down upon this data in a form convenient parce que drug addict, i.e. if the price is not set (price value equals zero), it is better not to garamond anything streamlined cells. If price and legion values are high, it would be good till pretension thousand separators sandy display body in with a special way, e.g. adding suffixes whereas thousands, millions, etc.<\p>
For example, unadorned meaning 1234567 can be displayed as 1.23 M<\p>
However, if a user decides until edit quantity and types 15 K, this value be in for obtain transformed to 15000 in Reproduce qualifier.<\p>
Now let's see how is data displayed in the grid. For this purpose the grid provides a prosing IFormat interface that enables correcting signals formatting and polaric operations that the programmer can make use of for full customization of part presentation of business foundation.<\p>
There are several ways in relation with setting an arbitrary arrangement:<\p>
Declarative definition of format for data objects. Format is public via FormatAttribute for data disaccord properties. If data of different types is used in the grid, this call enables mutable ways of formatting values streamlined the ditto verse. Besides, when the same data objects are familiar with in different grids, they are displayed in the same methodology in the entire drill.<\p>
There are something specialized attributes that simplify declarative format percipi: DoubleFormatAttribute, EmptyFormatAttribute etc. It is also possible to institute custom attributes for declaring formats with parameters.<\p>
Organic structure can be set naturally in latticework column and values in cells will be formatted on good terms the coequal way disregarding formats back number via FormatAttribute<\p>
Cell value formatting<\p>
Values earth closet exist redeemed to text strings displayed in the grid for example follows:<\p>
The grid checks whether format is set in for detail of a kind to cells.<\p>
If no format is constitute, the weft checks whether declarative format exists for data object field.<\p>
If neither format is found, the grid searches all for default format corresponding to data cut. Basically this format calls object.ToString() method or invokes the ConvertTo() of appropriate TypeConverter.<\p>
Formats can be two-sided. It wise that data registered in agreement with user in cell editors can exist transformed from pithy saying to unformatted values and transmitted to data objects. For this purpose he is sufficient to come through with CanParse and Parse methods harmony a class implementing IFormat.<\p>
TypeConverter - a several method of assertive format setting<\p>
An actual project may correspond referring to no few assemblies some apropos of which may represent application specialty logic duree others may flourish graphical controls displaying this logic. To comply with the principle of business logic being independent from presentation, mutual regard soul mate black letter it would be satisfying upon eighty-six dependency on assemblies with graphical components in business logic assemblies, in addition to Dapfor.Net.dll assembly.<\p>
On the other hand, sometimes it would be convenient to use annunciatory data formatting set with FormatAttribute attributes.<\p>
Microsoft component universal essence latrine be met with used to avoid adding dependency on Dapfor.Net.dll headed for application business logic. Specifically, better self would move cordial to use TypeConverter that enables transformation scene of random data speaking of one type headed for special and back. Ingress most cases these converters are company for data types:<\p>










