• Introduction
  • API Documentation
  • Sample Apps
  • GitHub

    Show / Hide Table of Contents
    • DynamicVML
      • AddNewDynamicItem
      • DynamicList<TViewModel, TOptions>
      • DynamicList<TViewModel>
      • DynamicListItem<TViewModel>
      • IDynamicList
      • IDynamicList<TValue>
      • IDynamicListItem
      • IDynamicListItem<TViewModel>
      • ListRenderMode
      • NewItemMethod
    • DynamicVML.Extensions
      • ControllerExtensions
      • EditorExtensions
      • EnumerableExtensions
      • ViewDataExtensions
    • DynamicVML.Internals
      • Constants
      • ItemDisplayParameters
      • ItemEditorParameters
      • ItemParameters
      • ListDisplayParameters
      • ListEditorParameters
      • ListParameters
      • Parameters
    • DynamicVML.Options
      • DynamicListAttribute
      • DynamicListDisplayOptions
      • DynamicListEditorOptions
      • DynamicListOptions

    Class ViewDataExtensions

    Contains extension methods for extracting and storing information related to DynamicList<TViewModel, TOptions> from ViewDataDictionary objects.

    Inheritance
    Object
    ViewDataExtensions
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: DynamicVML.Extensions
    Assembly: DynamicVML.dll
    Syntax
    public static class ViewDataExtensions

    Methods

    | Improve this Doc View Source

    GetDynamicListAttribute(ViewDataDictionary)

    Attempts to extract a DynamicListAttribute from the model's metadata stored in the Model property.

    Declaration
    public static DynamicListAttribute GetDynamicListAttribute(this ViewDataDictionary viewData)
    Parameters
    Type Name Description
    ViewDataDictionary viewData

    The view data containing the metadata to be inspected.

    Returns
    Type Description
    DynamicListAttribute

    A DynamicListAttribute object if one is set; otherwise null.

    | Improve this Doc View Source

    GetItemCreateParameters(ViewDataDictionary, String)

    Extracts a AddNewDynamicItem object from a ViewDataDictionary dictionary.

    Declaration
    public static AddNewDynamicItem GetItemCreateParameters(this ViewDataDictionary viewData, string itemId)
    Parameters
    Type Name Description
    ViewDataDictionary viewData

    The view data dictionary that should contain the object. If the object is not present, an ApplicationException will be thrown.

    String itemId

    The HTML div ID for the current list item.

    Returns
    Type Description
    AddNewDynamicItem

    The AddNewDynamicItem stored in the view data.

    | Improve this Doc View Source

    GetItemDisplayParameters(ViewDataDictionary, String, String)

    Retrieves the ItemDisplayParameters object stored in the ViewDataDictionary. If no ItemDisplayParameters is available, a new one will be created from the information stored in the ListDisplayParameters object that should have been stored in the ViewData.

    Declaration
    public static ItemDisplayParameters GetItemDisplayParameters(this ViewDataDictionary viewData, string itemId, string containerId = null)
    Parameters
    Type Name Description
    ViewDataDictionary viewData

    The view data object from where information will be extracted.

    String itemId

    The HTML div element ID for the current list item.

    String containerId

    The HTML div element ID for the current list.

    Returns
    Type Description
    ItemDisplayParameters
    | Improve this Doc View Source

    GetItemEditorParameters(ViewDataDictionary, String, AddNewDynamicItem, NewItemMethod)

    Re-creates a ItemEditorParameters from the partial information about the original list contained in a AddNewDynamicItem object. This information will be stored in the ViewDataDictionary in order to make the rest of the code work the same as much as possible.

    Declaration
    public static ItemEditorParameters GetItemEditorParameters(this ViewDataDictionary viewData, string itemId, AddNewDynamicItem newItemParameters, NewItemMethod method)
    Parameters
    Type Name Description
    ViewDataDictionary viewData

    The view data object from where information will be extracted.

    String itemId

    The HTML div element ID for the current list item.

    AddNewDynamicItem newItemParameters

    The AddNewDynamicItem parameters containing information about how the controller should create new items to be added to the list.

    NewItemMethod method

    The HTTP method used when calling the controller to add new items to the list.

    Returns
    Type Description
    ItemEditorParameters
    | Improve this Doc View Source

    GetItemEditorParameters(ViewDataDictionary, String, String)

    Retrieves the ItemEditorParameters object stored in the ViewDataDictionary. If no ItemEditorParameters is available, a new one will be created from the information stored in the ListEditorParameters object that should have been stored in the ViewData.

    Declaration
    public static ItemEditorParameters GetItemEditorParameters(this ViewDataDictionary viewData, string itemId, string containerId = null)
    Parameters
    Type Name Description
    ViewDataDictionary viewData

    The view data object from where information will be extracted.

    String itemId

    The HTML div element ID for the current list item.

    String containerId

    The HTML div element ID for the current list.

    Returns
    Type Description
    ItemEditorParameters
    | Improve this Doc View Source

    GetListDisplayParameters(ViewDataDictionary, String)

    Builds a new ListDisplayParameters object gathering information from different sources, including DynamicListDisplayOptions objects that may be stored in the view data, DynamicListAttribute attributes defined in the view model class, or, as a last resort, reflection.

    Declaration
    public static ListDisplayParameters GetListDisplayParameters(this ViewDataDictionary viewData, string containerId)
    Parameters
    Type Name Description
    ViewDataDictionary viewData

    The view data object from where information will be extracted.

    String containerId

    The HTML div element ID for the current list.

    Returns
    Type Description
    ListDisplayParameters

    A new ListDisplayParameters object with the actual values to be used when rendering the editor view for your view model.

    Remarks
    Warning

    This method will resort to reflecion in case the ItemTemplate, ActionUrl, or AddNewItemText have not been specified, which can incur a significant performance impact on the server. To avoid the extra performance hit, specify the name of the view you want to use for your view model when calling DisplayListFor<TModel, TValue>(IHtmlHelper<TModel>, Expression<Func<TModel, TValue>>, String, String, String, String, Object, ListRenderMode)

    | Improve this Doc View Source

    GetListEditorParameters(ViewDataDictionary, String)

    Builds a new ListEditorParameters object gathering information from different sources, including DynamicListEditorOptions objects that may be stored in the view data, DynamicListAttribute attributes defined in the view model class, or, as a last resort, reflection.

    Declaration
    public static ListEditorParameters GetListEditorParameters(this ViewDataDictionary viewData, string containerId)
    Parameters
    Type Name Description
    ViewDataDictionary viewData

    The view data object from where information will be extracted.

    String containerId

    The HTML div element ID for the current list.

    Returns
    Type Description
    ListEditorParameters

    A new ListEditorParameters object with the actual values to be used when rendering the editor view for your view model.

    Remarks
    Warning

    This method will resort to reflecion in case the ItemTemplate has not been specified, which can incur a significant performance impact on the server. To avoid the extra performance hit, specify the name of the view you want to use for your view model when calling ListEditorFor<TModel, TValue>(IHtmlHelper<TModel>, Expression<Func<TModel, TValue>>, String, String, String, String, String, String, Object, ListRenderMode, NewItemMethod)

    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 César Roberto de Souza - All files are available under the MIT license except the logo, which comes from FontAwesome.