WebGrid Constructor

Definition

Initializes a new instance of the WebGrid class.

public WebGrid (System.Collections.Generic.IEnumerable<dynamic> source = default, System.Collections.Generic.IEnumerable<string> columnNames = default, string defaultSort = default, int rowsPerPage = 10, bool canPage = true, bool canSort = true, string ajaxUpdateContainerId = default, string ajaxUpdateCallback = default, string fieldNamePrefix = default, string pageFieldName = default, string selectionFieldName = default, string sortFieldName = default, string sortDirectionFieldName = default);
new System.Web.Helpers.WebGrid : seq<obj> * seq<string> * string * int * bool * bool * string * string * string * string * string * string * string -> System.Web.Helpers.WebGrid
Public Sub New (Optional source As IEnumerable(Of Object) = null, Optional columnNames As IEnumerable(Of String) = null, Optional defaultSort As String = null, Optional rowsPerPage As Integer = 10, Optional canPage As Boolean = true, Optional canSort As Boolean = true, Optional ajaxUpdateContainerId As String = null, Optional ajaxUpdateCallback As String = null, Optional fieldNamePrefix As String = null, Optional pageFieldName As String = null, Optional selectionFieldName As String = null, Optional sortFieldName As String = null, Optional sortDirectionFieldName As String = null)

Parameters

source
IEnumerable<Object>

The data to display.

columnNames
IEnumerable<String>

A collection that contains the names of the data columns to display. By default, this value is auto-populated according to the values in the source parameter.

defaultSort
String

The name of the data column that is used to sort the grid by default.

rowsPerPage
Int32

The number of rows that are displayed on each page of the grid when paging is enabled. The default is 10.

canPage
Boolean

true to specify that paging is enabled for the WebGrid instance; otherwise false. The default is true.

canSort
Boolean

true to specify that sorting is enabled for the WebGrid instance; otherwise, false. The default is true.

ajaxUpdateContainerId
String

The value of the HTML id attribute that is used to mark the HTML element that gets dynamic Ajax updates that are associated with the WebGrid instance.

ajaxUpdateCallback
String

The name of the JavaScript function that is called after the HTML element specified by the AjaxUpdateContainerId property has been updated. If the name of a function is not provided, no function will be called. If the specified function does not exist, a JavaScript error will occur if it is invoked.

fieldNamePrefix
String

The prefix that is applied to all query-string fields that are associated with the WebGrid instance. This value is used in order to support multiple WebGrid instances on the same web page.

pageFieldName
String

The name of the query-string field that is used to specify the current page of the WebGrid instance.

selectionFieldName
String

The name of the query-string field that is used to specify the currently selected row of the WebGrid instance.

sortFieldName
String

The name of the query-string field that is used to specify the name of the data column that the WebGrid instance is sorted by.

sortDirectionFieldName
String

The name of the query-string field that is used to specify the direction in which the WebGrid instance is sorted.

Applies to