Class DynamicListAttribute
Represents an attribute which you can include in your view model's properties to indicate the property should be rendered as a Dynamic List. This class inherits from UIHintAttribute.
Inherited Members
Namespace: DynamicVML.Options
Assembly: DynamicVML.dll
Syntax
public class DynamicListAttribute : UIHintAttribute
Remarks
Instead of specifying each of your views to add the extra parameters to EditorFor()
,
you can alternatively configure the DynamicList properties of your view models directly
in your view model class definition using this attribute:
public class AuthorViewModel
{
public string FirstName { get; set; }
public string LastName { get; set; }
[Display(Name = "Authored books")]
[DynamicList("BookView",
ItemContainerTemplate = "MyCustomItemContainer",
ListTemplate = "MyCustomList",
Method = RequestNewItemMethod.Post)]
public virtual DynamicList<BookViewModel> Books { get; set; } =
new DynamicList<BookViewModel>();
}
Note
While this is possible, this is not exactly recommended as one could argue that specifying view parameters in your view models may add unnecessary coupling between your code and the presentation layer. However, if you really want to specify parameters this way, the library will let you do so.
Constructors
| Improve this Doc View SourceDynamicListAttribute(String)
Initializes a new instance of the DynamicListAttribute class.
Declaration
public DynamicListAttribute(string listContainerTemplate = "DynamicListContainer")
Parameters
Type | Name | Description |
---|---|---|
String | listContainerTemplate | The template for the list container. For more details about the different regions associated with a DynamicList<TViewModel, TOptions>, please EditorExtensions. |
Properties
| Improve this Doc View SourceItemContainerTemplate
Gets or sets the item container template to be used when displaying a list for this attribute. For more details about the different regions associated with a DynamicList<TViewModel, TOptions>, please EditorExtensions.
Declaration
public string ItemContainerTemplate { get; set; }
Property Value
Type | Description |
---|---|
String |
ItemTemplate
Gets or sets the item template to be used when displaying a list for this attribute. This should normally be your view for the view models you are using. If you do not specify a view name, the library will attempt to find one based on your view model's class name. For more details about the different regions associated with a DynamicList<TViewModel, TOptions>, please EditorExtensions.
Declaration
public string ItemTemplate { get; set; }
Property Value
Type | Description |
---|---|
String |
ListContainerTemplate
Gets or sets the list container template to be used when displaying a list for this attribute. For more details about the different regions associated with a DynamicList<TViewModel, TOptions>, please EditorExtensions.
Declaration
public string ListContainerTemplate { get; }
Property Value
Type | Description |
---|---|
String |
ListTemplate
Gets or sets the list template to be used when displaying a list for this attribute. For more details about the different regions associated with a DynamicList<TViewModel, TOptions>, please EditorExtensions.
Declaration
public string ListTemplate { get; set; }
Property Value
Type | Description |
---|---|
String |
Method
Gets or sets whether to use Get or Post when requesting new list items from the server. Default is to use Get.
Declaration
public NewItemMethod Method { get; set; }
Property Value
Type | Description |
---|---|
NewItemMethod |
Mode
Gets or sets whether the view for your viewmodel should receive a @model of type
YourOptions<YourViewModel>
or simply YourViewModel
. Default is to
use ViewModelOnly (so your view will receive just
your view model, without its associated options object.
Declaration
public ListRenderMode Mode { get; set; }
Property Value
Type | Description |
---|---|
ListRenderMode |