Skip to content

Handle the client-side FocusedCellChanging event to cancel a focus action for ASPxGridView cells. The canceled focus action prevents users from editing the corresponding cell in batch edit mode.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/aspxgridview-prevent-batch-edit-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid View for ASP.NET Web Forms - Prevent the cell edit action on the client in batch edit mode

This example handles the client-side FocusedCellChanging event to disable the cell edit action in batch edit mode based on a condition defined in code.

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

Implementation Details

The following client-side FocusedCellChanging event handler sets the e.Cancel property to true 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 about the clicked cell.

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;
}

Files to Look At

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Handle the client-side FocusedCellChanging event to cancel a focus action for ASPxGridView cells. The canceled focus action prevents users from editing the corresponding cell in batch edit mode.

Topics

Resources

License

Stars

Watchers

Forks