Back to Devexpress

GridViewSettings.CustomJSProperties Property

aspnetmvc-devexpress-dot-web-dot-mvc-dot-gridviewsettings-1eb523e2.md

latest3.9 KB
Original Source

GridViewSettings.CustomJSProperties Property

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

Namespace : DevExpress.Web.Mvc

Assembly : DevExpress.Web.Mvc5.v25.2.dll

NuGet Package : DevExpress.Web.Mvc5

Declaration

csharp
public ASPxGridViewClientJSPropertiesEventHandler CustomJSProperties { get; set; }
vb
Public Property CustomJSProperties As ASPxGridViewClientJSPropertiesEventHandler

Property Value

TypeDescription
ASPxGridViewClientJSPropertiesEventHandler

A ASPxGridViewClientJSPropertiesEventHandler delegate method allowing you to implement custom processing.

|

Remarks

In some instances, it is necessary to obtain server information on the client. The delegate method defined by the CustomJSProperties property enables you to declare temporary client properties. Once declared, a property can be accessed on the client.

To add new properties, use the parameter’s CustomJSPropertiesEventArgs.Properties property, which represents a collection of property names and their values. The only requirement is that property names must begin with the ‘cp’ prefix, to avoid rewriting the base properties exposed by the GridView extension.

Concept

How to Access Server Data on the Client Side

Online Demo

GridView - Select All Rows

Example

razor
Html.DevExpress().GridView(settings => {
    settings.Name = "grid";
    settings.CallbackRouteValues = new { Action = "AdvancedSelectionPartial", Controller = "Selection" };
    ...
    settings.CustomJSProperties = (s, e) => {
        var grid = s as MVCxGridView;
        e.Properties["cpVisibleRowCount"] = grid.VisibleRowCount;
        e.Properties["cpFilteredRowCountWithoutPage"] = GetFilteredRowCountWithoutPage(grid);
    };
}).Bind(Model).GetHtml()

Online Examples

See Also

Declaring Server-Side Event Handlers

How to Access Server Data on the Client Side

Grid View

GridViewSettings Class

GridViewSettings Members

DevExpress.Web.Mvc Namespace