Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DataGridBuilder<T>.ID(JS) Method

Specifies the id attribute for the control’s HTML element (used for nested controls within templates).

Namespace: DevExtreme.AspNet.Mvc.Builders

Assembly: DevExtreme.AspNet.Core.dll

#Declaration

C#
public DataGridBuilder<T> ID(
    JS expr
)

#Parameters

Name Type Description
expr JS

A JavaScript expression that specifies the id attribute value.

#Returns

Type Description
DataGridBuilder<T>

A reference to this instance after the method is called.

#Remarks

Use this method when you nest the DataGrid control within a template. The method allows you to specify the id attribute for the control’s HTML element. To do this, use the new JS() expression. Refer to ID Option: Nested Controls in Templates for more information.

@using(Html.DevExtreme().NamedTemplate("myTemplate")) {
    @(Html.DevExtreme().DataGrid()
        .ID(new JS("'dataGrid_' + ID"))
    )
}

After you specify the id attribute, you can use it to access the control’s JavaScript API at runtime (for example, to call methods).

See Also