Smart Design. Additional Views

The first feature of XafariSmartDesignStrategy is to create new Views and define their layout in code. This feature is provided by the CreateListView and CreateDetailView attributes.

CreateDetailView attribute

Decorates business classes with the CreateDetailView attribute to define an additional Detail View for a particular business object.

  • c#
  • VB

[CreateDetailView(Id = "XafariViewLayoutGeneratorObject_Code1_DetailView")]
public class XafarSmartDesignObject : BaseObject
{//...
}

<CreateDetailView(Id := "XafariViewLayoutGeneratorObject_Code1_DetailView")> _
Public Class XafarSmartDesignObject
  Inherits BaseObject
  '...
End Class

The Id property specifies the unique identifier for the new View. The image below shows two nodes in the Application Model: the node of the default Detail View and the node of the XafariViewLayoutGeneratorObject_Code1 Detail View. The Additional View does not contain any fields yet.

smart_design_7

Note:

It is possible to use the Create(List/Detail)View attribute without specifying the Id parameter. In this case, the new View will not be created (the default View will be used instead). However, this default View will satisfy other parameters specified in the attribute. The Create(List/Detail)View attribute parameters take precedence over the attributes that customize the default View (see the Default View Customisation section in this topic).

Note

Both the CreateListView and CreateDetailView attributes have the LayoutStrategy property allowing to set XafariSmartDesignStrategy or XafSmartDesignStrategy for a particular View.

To customize the layout of the new View, use the Layout property. In the case of the CreateDetailView attribute, the Layout property is a string that lists the name of each property which the View Item should be generated for. All property names are separated by semicolons, and the View Items are generated in the listed order.

smart_design_8

To organize a group of properties, enclose the required items with square brackets, and separate them by commas. Finally, specify the group name before the brackets. The code snippet below demonstrates the group constructions inside the Layout string.

  • c#
  • VB

[CreateDetailView(Id = "XafariViewLayoutGeneratorObject_Code1_DetailView", Layout = "Integer;Long;String;" + "GroupByte[Byte,Byte,Byte];" + "GroupDecimal[Decimal,Decimal,Decimal];")]
public class XafarSmartDesignObject : BaseObject
{//...
}

<CreateDetailView(Id := "XafariViewLayoutGeneratorObject_Code1_DetailView", Layout := "Integer;Long;String;" + "GroupByte[Byte,Byte,Byte];" + "GroupDecimal[Decimal,Decimal,Decimal];")> _
Public Class XafarSmartDesignObject
  Inherits BaseObject
  '...
End Class

If the property is not tied to a group, it should fall into the group named "General" (it is always located at the top of the Detail View).

smart_design_9

CreateListView attribute

Decorates business classes with the CreateListView attribute to define an additional List View for a business object.

  • c#
  • VB

[CreateListView(Id = "XafariViewLayoutGeneratorObject_Code1_LookupListView", Layout = "Integer;Long;String", ListViewType = ListViewType.LookupListView)]
public class XafarSmartDesignObject : BaseObject
{//...
}

<CreateListView(Id := "XafariViewLayoutGeneratorObject_Code1_LookupListView", Layout := "Integer;Long;String", ListViewType := ListViewType.LookupListView)> _
Public Class XafarSmartDesignObject
  Inherits BaseObject
  '...
End Class

In the case of the CreateListView attribute, the Layout property is a string that lists the name of each property which the column should be generated for. All property names are separated by semicolons, and the columns are generated in the listed order.

smart_design_10

In addition to Id and Layout, the CreateListView attribute supports a few specific parameters:

  • ListViewType
  • EditorAlias
  • IsDefaultTreeListView
  • IsDefaultGridListView

ListViewType specifies the type of the future List View. If this parameter is not specified, the default value is "ViewType.ListView".

The EditorAlias string specifies the Alias of the List Editor which will display the future List View. If this parameter is not specified, the default editor is used.

The IsDefaultTreeListView and IsDefaultGridListView bool properties are actual only for hierarchical data. For the business objects that implement the IHierarchyNode interface, Xafari extends the corresponding BO nodes with the DefaultTreeListView and DefaultGridListView properties.

smart_design_3

These properties can be set using the appropriate parameters of the CreateListView attribute:

  • IsDefaultTreeListView indicates that the created List View should be DefaultTreeListView.
  • IsDefaultGridListView indicates that the created List View should be DefaultGridListView.

Note

To get acquainted with more advanced customizations, refer to the Xafari.FeatureCenter.XafariSmartDesignGenerator|XafarSmartDesignObject.cs file in the Feature Center demo installed with Xafari. By default, the Feature Center demo is installed in %PUBLIC%\Documents\Xafari Framework v16.1.6011 Demos\FeatureCenter.