This project is read-only.

DisplayField Helper 

The DisplayField helper has two functions: 

  1. It  associates a Javascript id to a property in display mode. This enables the synchronization of several data representing the same property as in the case of a DetailForm associated with a DataGrid
  2. It formats the data according to the information supplied by the [DisplayFormat] data annotation. The format specified there can be overriden by specifying a not null value for the optional format parameter.

The DisplayFormat attribute has also two optional array arguments that are used to display values for boolean and enumeration fields. The first arguments supplies a list of strings, while the second one a list of image urls. For each value of the enumeration, bool? or bool it  associate an integer with its actual value according to the following rules:

  1. For bool values true is associated with 1 and false with 0;
  2. For bool? values null is associated with 0, 1 with false and 2 with true;
  3. In case of  enumerations the enumeration is converted into an int32 by means of the Convert class.

Then it tries to find an image url at the index postion specified by the previously computed integer, if it fails back up on a string value. One can therefore mix both images and strings.

In case of bool values if neither of the two arrays is supplied the value is displayed by means of a disabled checkbox. In case of enumerations, instead,  if neither of the two arrays supplies a value for an element the element is converted into a string using the Convert class.

Last edited Jun 22, 2014 at 11:57 AM by frankabbruzzese, version 5


No comments yet.