aspnetmvc-16077-components-site-navigation-and-layout-form-layout-item-manipulation.md
With the FormLayout , you can easily create form layouts of any complexity by combining the order and hierarchy of the provided layout elements. The main layout elements of the FormLayout consist of labeled items, labeled regular groups and tabbed groups.
This topic describes how to manipulate layout items and groups within the FormLayout.
Item elements serve as placeholders for ASP.NET MVC helpers and extensions or custom content. Group elements are containers for other layout elements. It is possible to nest one group inside another group.
Items can be created in two ways:
The following actions are available.
Adding a layout item.
Adding a regular or tabbed layout group.
Creating a multicolumn layout and using an empty layout item.
Note
If an item type (specified using the MVCxFormLayoutItem.NestedExtensionType property) is not set explicitly, the FormLayout creates a default item, applies your settings to it and uses a corresponding model property to determine a required type. Once the type is determined, the default Layout item is removed, and another item or a required type is created. Note that in this scenario, the FormaLayout gets access to the Model only during data binding, at which time your settings have been already applied to the default item. So, they do not apply to the new item again.
To solve this issue, you can do the following.
groupSettings.Items.Add(itemSettings => {
itemSettings.FieldName = "Description";
itemSettings.NestedExtensionType = FormLayoutNestedExtensionItemType.TextBox; //required type here
itemSettings.NestedExtensionSettings.Width = Unit.Percentage(100);
});
groupSettings.Items.Add(m => m.Description, itemSettings =>
{
itemSettings.FieldName = "Description";
itemSettings.NestedExtensionSettings.Width = Unit.Percentage(100);
});
See Also