Skip to main content

ASPxClientGridViewBatchEditApi.ValidateRow(visibleIndex) Method

Validates data in the specified row when the grid is in batch edit mode.

Declaration

ValidateRow(
    visibleIndex: number
): boolean

Parameters

Name Type Description
visibleIndex number

The row’s visible index.

Returns

Type Description
boolean

true if data in the specified row is valid; otherwise, false.

Remarks

The ValidateRow method allows you to validate data in the specified row on the client side.

To validate all grid rows, call the ValidateRows method.

<dx:ASPxGridView ID="Grid" ClientInstanceName="ClientGrid" runat="server" ...>
    <!-- ... -->
    <SettingsEditing Mode="Batch">
        <BatchEditSettings AllowValidationOnEndEdit="false" />
    </SettingsEditing>
    <ClientSideEvents BatchEditRowValidating="OnBatchEditRowValidating"/>
</dx:ASPxGridView>
<dx:ASPxButton ID="Button" runat="server" Text="Validate new rows" AutoPostBack="false">
    <ClientSideEvents Click="ValidateNewRows" />
</dx:ASPxButton>
function ValidateNewRows(s, e) {
    var batchApi = ClientGrid.batchEditApi;
    var newRows = batchApi.GetUnsavedChanges().insertedValues;
    // The GetUnsavedChanges method uses visible indexes to identify new rows
    for (var index in newRows) {
        batchApi.ValidateRow(index);
    }
}

function OnBatchEditRowValidating(s, e) {
    for (var columnIndex in e.validationInfo) {
        var validationInfo = e.validationInfo[columnIndex];
        if (validationInfo.value === null) {
            validationInfo.isValid = false;
            validationInfo.errorText = "Invalid data";
        }
    }
}

For more information on the grid in batch edit mode, refer to the following topic: ASPxGridView - Batch Edit Mode.

See Also