Class EditorExtensions
Contains extension methods for rendering different parts of the list from .cshtml view files.
Inherited Members
Namespace: DynamicVML.Extensions
Assembly: DynamicVML.dll
Syntax
public static class EditorExtensions
Remarks
The methods in this class can be used to render different regions of a dynamic list from within a view. A quick reference for the regions can be seen in the figure below:
Methods
| Improve this Doc View SourceDisplayListFor<TModel, TValue>(IHtmlHelper<TModel>, Expression<Func<TModel, TValue>>, String, String, String, String, Object, ListRenderMode)
Renders a dynamic list for display. Please see the image in the remarks section for a quick understanding of all the different templates that can be specified.
Declaration
public static IHtmlContent DisplayListFor<TModel, TValue>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TValue>> propertyExpression, string itemTemplate = null, string itemContainerTemplate = null, string listTemplate = null, string listContainerTemplate = "DynamicListContainer", object additionalViewData = null, ListRenderMode mode = ListRenderMode.ViewModelOnly)
where TValue : IDynamicList
Parameters
Type | Name | Description |
---|---|---|
IHtmlHelper<TModel> | html | The IHtmlHelper<TModel> from your current view. |
Expression<Func<TModel, TValue>> | propertyExpression | An expresion to be evaluated against the current model. |
String | itemTemplate | The view name for the view models to be displayed. |
String | itemContainerTemplate | The template for the "DynamicItemContainer" part of the list. |
String | listTemplate | The template for the "DynamicList" part of the list. |
String | listContainerTemplate | The template for the "DynamicListContainer" part of the list. |
Object | additionalViewData | An anonymous object or Dictionary<TKey,TValue> that can contain additional view data that will be merged into the ViewDataDictionary instance created for the template. |
ListRenderMode | mode | The ListRenderMode to be used when rendering the template for your view model. Please see the ListRenderMode for more details. |
Returns
Type | Description |
---|---|
IHtmlContent | The rendered HTML for the list. |
Type Parameters
Name | Description |
---|---|
TModel | The type of the model object in your current view. |
TValue | The list to be displayed. |
Remarks
GetDynamicListActionUrl(IHtmlHelper<IDynamicList>)
Gets a string with information about how request a new item from the server. Please see GetActionInfo() for more information.
Declaration
public static string GetDynamicListActionUrl(this IHtmlHelper<IDynamicList> html)
Parameters
Type | Name | Description |
---|---|---|
IHtmlHelper<IDynamicList> | html | The IHtmlHelper<TModel> associated with the current view. |
Returns
Type | Description |
---|---|
String | A string containing information to be passed to the JavaScript scripts. |
ListEditorFor<TModel, TValue>(IHtmlHelper<TModel>, Expression<Func<TModel, TValue>>, String, String, String, String, String, String, Object, ListRenderMode, NewItemMethod)
Renders a dynamic list for display. Please see the image in the EditorExtensions remarks section to get a quick understanding of which part this refers to.
Declaration
public static IHtmlContent ListEditorFor<TModel, TValue>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TValue>> propertyExpression, string actionUrl = null, string addNewItemText = null, string itemTemplate = null, string itemContainerTemplate = null, string listTemplate = null, string listContainerTemplate = "DynamicListContainer", object additionalViewData = null, ListRenderMode mode = ListRenderMode.ViewModelOnly, NewItemMethod method = NewItemMethod.Get)
where TValue : IDynamicList
Parameters
Type | Name | Description |
---|---|---|
IHtmlHelper<TModel> | html | The IHtmlHelper<TModel> from your current view. |
Expression<Func<TModel, TValue>> | propertyExpression | An expresion to be evaluated against the current model. |
String | actionUrl | The path to the controller action responsible for generating the view for a new item. |
String | addNewItemText | The text to be displayed in the button that the user can click to add a new item to the list. |
String | itemTemplate | The view name for the view models to be displayed. |
String | itemContainerTemplate | The template for the "DynamicItemContainer" part of the list. |
String | listTemplate | The template for the "DynamicList" part of the list. |
String | listContainerTemplate | The template for the "DynamicListContainer" part of the list. |
Object | additionalViewData | An anonymous object or Dictionary<TKey,TValue> that can contain additional view data that will be merged into the ViewDataDictionary instance created for the template. |
ListRenderMode | mode | The ListRenderMode to be used when rendering the template for your view model. Please see the ListRenderMode for more details. |
NewItemMethod | method | The NewItemMethod to use, whether Get or Post. |
Returns
Type | Description |
---|---|
IHtmlContent | The rendered HTML for the list. |
Type Parameters
Name | Description |
---|---|
TModel | The type of the model object in your current view. |
TValue | The list to be displayed. |
Remarks
Warning
The additionalViewData
object will not be sent back to the server when the user clicks the "Add new item" button if
method
is also set to Get. However, it will
still be passed to the templates during the first rendering of the list. In order to be able
to receive the additional data from the controller, please also specify
method
: NewItemMethod.Post
.
RenderDynamicItemContainerDisplay<TModel>(IHtmlHelper<TModel>, String)
Renders the "DynamicItemContainer" part of the list to the view. Please see the image in the EditorExtensions remarks section to get a quick understanding of which part this refers to.
Declaration
public static IHtmlContent RenderDynamicItemContainerDisplay<TModel>(this IHtmlHelper<TModel> html, string itemId)
where TModel : IDynamicList
Parameters
Type | Name | Description |
---|---|---|
IHtmlHelper<TModel> | html | The IHtmlHelper<TModel> from your current view. |
String | itemId | The div id (key of the item in the DynamicList<TViewModel, TOptions>) for the current item being rendered. |
Returns
Type | Description |
---|---|
IHtmlContent | An awaitable async task. |
Type Parameters
Name | Description |
---|---|
TModel | The type of the model object in your current view. |
RenderDynamicItemContainerEditor<TModel>(IHtmlHelper<TModel>, String)
Renders the "DynamicItemContainer" part of the list to the view. Please see the image in EditorExtensions remarks section to get a quick understanding of which part this refers to.
Declaration
public static IHtmlContent RenderDynamicItemContainerEditor<TModel>(this IHtmlHelper<TModel> html, string itemId)
where TModel : IDynamicList
Parameters
Type | Name | Description |
---|---|---|
IHtmlHelper<TModel> | html | The IHtmlHelper<TModel> from your current view. |
String | itemId | The div id (key of the item in the DynamicList<TViewModel, TOptions>) for the current item being rendered. |
Returns
Type | Description |
---|---|
IHtmlContent | An awaitable async task. |
Type Parameters
Name | Description |
---|---|
TModel | The type of the model object in your current view. |
RenderDynamicItemDisplay<TModel>(IHtmlHelper<TModel>)
Renders the "Item" part of the list to the view. This corresponds to your actual user-provided view for your current viewmodel. Please see the image in EditorExtensions remarks section to get a quick understanding of which part this refers to.
Declaration
public static IHtmlContent RenderDynamicItemDisplay<TModel>(this IHtmlHelper<TModel> html)
where TModel : IDynamicListItem
Parameters
Type | Name | Description |
---|---|---|
IHtmlHelper<TModel> | html | The IHtmlHelper<TModel> from your current view. |
Returns
Type | Description |
---|---|
IHtmlContent | An awaitable async task. |
Type Parameters
Name | Description |
---|---|
TModel | The type of the model object in your current view. |
RenderDynamicItemEditor<TModel>(IHtmlHelper<TModel>)
Renders the "Item" part of the list to the view. This corresponds to your actual user-provided view for your current viewmodel. Please see the image in EditorExtensions remarks section to get a quick understanding of which part this refers to.
Declaration
public static IHtmlContent RenderDynamicItemEditor<TModel>(this IHtmlHelper<TModel> html)
where TModel : IDynamicListItem
Parameters
Type | Name | Description |
---|---|---|
IHtmlHelper<TModel> | html | The IHtmlHelper<TModel> from your current view. |
Returns
Type | Description |
---|---|
IHtmlContent | An awaitable async task. |
Type Parameters
Name | Description |
---|---|
TModel | The type of the model object in your current view. |
RenderDynamicListAddNewItemText(IHtmlHelper<IDynamicList>)
Renders the "Add new item" text that have been defined in the AddNewItemText to the view.
Declaration
public static string RenderDynamicListAddNewItemText(this IHtmlHelper<IDynamicList> html)
Parameters
Type | Name | Description |
---|---|---|
IHtmlHelper<IDynamicList> | html | The IHtmlHelper<TModel> associated with the current view. |
Returns
Type | Description |
---|---|
String | A string containing the specified text, e.g., "Add new book". |
RenderDynamicListDisplay<TModel>(IHtmlHelper<TModel>)
Renders the "DynamicList" part of the list to the view. Please see the image in EditorExtensions remarks section to get a quick understanding of which part this refers to.
Declaration
public static void RenderDynamicListDisplay<TModel>(this IHtmlHelper<TModel> html)
where TModel : IDynamicList
Parameters
Type | Name | Description |
---|---|---|
IHtmlHelper<TModel> | html | The IHtmlHelper<TModel> from your current view. |
Type Parameters
Name | Description |
---|---|
TModel | The type of the model object in your current view. |
RenderDynamicListEditor<TModel>(IHtmlHelper<TModel>)
Renders the "DynamicList" part of the list to the view. Please see the image in EditorExtensions remarks section to get a quick understanding of which part this refers to.
Declaration
public static void RenderDynamicListEditor<TModel>(this IHtmlHelper<TModel> html)
where TModel : IDynamicList
Parameters
Type | Name | Description |
---|---|---|
IHtmlHelper<TModel> | html | The IHtmlHelper<TModel> from your current view. |
Type Parameters
Name | Description |
---|---|
TModel | The type of the model object in your current view. |