Back to Devexpress

ASPxGridBase.JSProperties Property

aspnet-devexpress-dot-web-dot-aspxgridbase-d1675f9d.md

latest3.9 KB
Original Source

ASPxGridBase.JSProperties Property

Enables you to supply any server with data that can then be parsed on the client.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public Dictionary<string, object> JSProperties { get; }
vb
Public ReadOnly Property JSProperties As Dictionary(Of String, Object)

Property Value

TypeDescription
Dictionary<String, Object>

The collection of property names and their values.

|

Remarks

In some instances, it is necessary to obtain server information on the client. The JSProperties property enables you to declare temporary client properties. The JSProperties property represents a collection of property names and their values. Once declared, a property can be accessed on the client.

Note

The only requirement is that property names must begin with the ‘cp’ prefix, to avoid rewriting the control’s base properties.

Example

Web Forms approach:

csharp
protected void grid_RowUpdated(object sender, DevExpress.Web.Data.ASPxDataUpdatedEventArgs e) {
    (sender as ASPxGridView).JSProperties["cpResult"] = returnValue;
}

MVC approach:

razor
settings.BeforeGetCallbackResult = (s, e) => {
    MVCxGridView grid = (MVCxGridView)s;
    if (grid.Selection.Count > 0)
        grid.JSProperties["cpSelectedRowKey"] = grid.GetSelectedFieldValues("Id")[0].ToString();
    else {
        grid.JSProperties["cpSelectedRowKey"] = false;
    }
};
js
function InvoiceGrid_OnEndCallback(s, e) {
    if (s.cpSelectedRowKey)
        alert(s.cpSelectedRowKey);
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the JSProperties property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

web-forms-pivot-grid-obtain-underlying-data/CS/ASPxPivotGrid_DisplayUnderlyingRecords/Default.aspx.cs#L21

csharp
ASPxGridView1.PageIndex = 0;
    ASPxGridView1.JSProperties["cpShowDrillDownWindow"] = true;
}

web-forms-pivot-grid-obtain-underlying-data/VB/ASPxPivotGrid_DisplayUnderlyingRecords/Default.aspx.vb#L20

vb
ASPxGridView1.PageIndex = 0
    ASPxGridView1.JSProperties("cpShowDrillDownWindow") = True
End If

See Also

Passing Values from the Server to the Client

Callbacks

ASPxGridBase Class

ASPxGridBase Members

DevExpress.Web Namespace