Skip to content

Dmitry-Duda/aspxgridview-batch-edit-cancel-editor-row-editing-in-the-client-focusedcellchanging-event-t496531

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ASP.NET - Handle the client-side FocusedCellChanging event to prevent an edit action for ASPxGridView cells

This example handles the client-side FocusedCellChanging event to prevent users from editing corresponding grid cells in batch edit mode.

[Run Online]

Files to Look At

Implementation Details

The following client-side FocusedCellChanging event handler specifies the e.Cancel property to cancel the focus action (and subsequent edit operations) for cells in specific columns and rows. The code uses the e.cellInfo event property to get information on the clicked cell's column and row.

function onFocusedCellChanging(s, e) {
    if (e.cellInfo.column.name == 'command')
        e.cancel = true;
    else if (e.cellInfo.column.fieldName == 'SupplierID')
        e.cancel = true;
    else if (e.cellInfo.column.fieldName == 'UnitsInStock' && (e.cellInfo.rowVisibleIndex < 3 || e.cellInfo.rowVisibleIndex > 7))
        e.cancel = true;
    else if (e.cellInfo.column.fieldName == 'UnitPrice' && s.batchEditApi.GetCellValue(e.cellInfo.rowVisibleIndex, 'UnitPrice') > 22)
        e.cancel = true;
}

This technique is not applicable if you set the EditMode property to Row. A user can focus and edit any cell in the row switched to edit mode except for cells in read-only columns (the GridViewDataColumn.ReadOnly property).

About

.NET, ASP.NET Web Forms, ASPxGridView

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • ASP.NET 74.7%
  • C# 25.3%