Class AddNewDynamicItem
Represents the data object that the client can send to the server to request a new partial view for a new list item using ajax. When the controller creates this new partial view, an instance of this class will be stored in the ViewDataDictionary object of the views under the key ItemCreateParameters.
Inherited Members
Namespace: DynamicVML
Assembly: DynamicVML.dll
Syntax
public class AddNewDynamicItem
Remarks
An instance of this class should be specified as the single argument of the controller action that should handle the creation of a new item in your application. In addition, your controller action must end by calling one of the PartialView(Controller, IDynamicList, AddNewDynamicItem) overloads that will take care of rendering the new item for you. An example can be seen below:
[HttpGet]
public IActionResult AddBook(AddNewDynamicItem parameters)
{
var newBookViewModel = new BookViewModel()
{
Title = "New book",
PublicationYear = "1994"
};
return this.PartialView(newBookViewModel, parameters);
}
Note
Under normal circumstances, this class should never need to be instantiated directly by your code as it is part of the inner workings of the library.
Constructors
| Improve this Doc View SourceAddNewDynamicItem()
Creates a new instance of the AddNewDynamicItem class. This is an empty constructor that is necessary to be present in order for IModelBinder deserialize objects of this class correctly.
Declaration
public AddNewDynamicItem()
AddNewDynamicItem(String, String, String, String, String, ListRenderMode, Object)
Creates a new instance of AddNewDynamicItem.
Declaration
public AddNewDynamicItem(string containerId, string listTemplate, string itemContainerTemplate, string itemTemplate, string prefix, ListRenderMode mode, object additionalViewData)
Parameters
Type | Name | Description |
---|---|---|
String | containerId | |
String | listTemplate | |
String | itemContainerTemplate | |
String | itemTemplate | |
String | prefix | |
ListRenderMode | mode | |
Object | additionalViewData |
Properties
| Improve this Doc View SourceAdditionalViewData
Gets or sets any additional view data which may have been passed by the user when calling the ListEditorFor<TModel, TValue>(IHtmlHelper<TModel>, Expression<Func<TModel, TValue>>, String, String, String, String, String, String, Object, ListRenderMode, NewItemMethod) extension method, represented by an UTF-8 byte array that can be serialized to JSON and posted back to the server.
Declaration
public byte[] AdditionalViewData { get; set; }
Property Value
Type | Description |
---|---|
Byte[] |
ContainerId
Gets or sets the HTML div ID for the list whose new item should be created for.
Declaration
public string ContainerId { get; set; }
Property Value
Type | Description |
---|---|
String |
DisableTraceWarningsForQueryStringsThatContainAdditionalViewData
Self explanatory.
Declaration
public static bool DisableTraceWarningsForQueryStringsThatContainAdditionalViewData { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
By default, the library will generate a TraceWarning(String) if you
specify any additionalViewData
to the ListEditorFor<TModel, TValue>(IHtmlHelper<TModel>, Expression<Func<TModel, TValue>>, String, String, String, String, String, String, Object, ListRenderMode, NewItemMethod)
method while also specifying the HTTP method as Get. Setting
this static property to false
will disable those warnings globally.
ItemContainerTemplate
Gets or sets the ItemContainerTemplate to be used when creating the new item.
Declaration
public string ItemContainerTemplate { get; set; }
Property Value
Type | Description |
---|---|
String |
ItemTemplate
Gets or sets the ItemTemplate to be used when creating the new item.
Declaration
public string ItemTemplate { get; set; }
Property Value
Type | Description |
---|---|
String |
ListTemplate
Gets or sets the ListTemplate to be used when creating the new item.
Declaration
public string ListTemplate { get; set; }
Property Value
Type | Description |
---|---|
String |
Mode
Gets or sets the ListRenderMode to be used when creating the new item.
Declaration
public ListRenderMode Mode { get; set; }
Property Value
Type | Description |
---|---|
ListRenderMode |
Prefix
Gets or sets the HTML prefix to be used when creating the new item.
Declaration
public string Prefix { get; set; }
Property Value
Type | Description |
---|---|
String |
Methods
| Improve this Doc View SourceGetAdditionalViewData()
Gets the additional view data at AdditionalViewData as a Dictionary<TKey,TValue> containing the key-value pairs in the AdditionalViewData.
Declaration
public Dictionary<string, string> GetAdditionalViewData()
Returns
Type | Description |
---|---|
Dictionary<String, String> | A Dictionary<TKey,TValue> representing the contents of the AdditionalViewData property of this class. |
ToJSON()
Converts this instance to a JSON representation that can be sent to the server.
Declaration
public string ToJSON()
Returns
Type | Description |
---|---|
String | A JSON containing the key-value pairs of the properties of this class. |
ToQueryString()
Converts this instance to a GET query string representation that can be sent to the server.
Declaration
public string ToQueryString()
Returns
Type | Description |
---|---|
String | An HTTP GET query string containing the key-value pairs of the properties of this class, e.g.:
|
Remarks
Warning
Additional user data is never included in the query string. See ListEditorFor<TModel, TValue>(IHtmlHelper<TModel>, Expression<Func<TModel, TValue>>, String, String, String, String, String, String, Object, ListRenderMode, NewItemMethod) for more details.