Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
220
Get Edited Rows Collection on Client Side upon Button Click
posted

Hi,

For a webdatagrid that is in CellEditing behavior enabled,

How can i get to the collection of those rows that was edited from client side based on a button click? (I am looking to do some validations in client side)
I am looking for something like the below:

var grid = $find("gridid");
var gridBehaviors = grid.get_behaviors(); //get grid behaviors
var gridEditBehaviors = gridBehaviors.get_editingCore().get_behaviors().get_cellEditing(); // get cell editing behavior
// get the edited rows collection from the cell editing behavior (How to?)
// iterate throw each rows from the rows collection and get to each cell value that got changed (how to?)

Our Server Side(Logic of setting grid in Cell Editing Mode):

grdDataTable.Behaviors.GetBehavior(Of EditingCore)().Enabled = True
grdDataTable.Behaviors.GetBehavior(Of EditingCore)().EnableInheritance = True
grdDataTable.Behaviors.GetBehavior(Of EditingCore)().AutoCRUD = False
grdDataTable.Behaviors.GetBehavior(Of EditingCore)().BatchUpdating = True

Dim _cellEditingBehavior As CellEditing = New CellEditing()

' Define and add the cell editing behavior
_cellEditingBehavior.Enabled = True
_cellEditingBehavior.EditModeActions.EnableOnActive = True
_cellEditingBehavior.EditModeActions.MouseClick = EditMouseClickAction.Single

grdDataTable.Behaviors.GetBehavior(Of EditingCore)().Behaviors.Add(_cellEditingBehavior)

Thanks,
Aravind

Parents
  • 16210
    Verified Answer
    Offline posted

    Hi Aravind,

    First, you will need to manually save the column keys of the columns, whose cells were edited. This can happen in the ExitingEditMode or ExitedEditMode event:

    function WebDataGrid1_CellEditing_ExitingEditMode(sender, eventArgs)
    {
        var columnKey = eventArgs.getCell().get_column().get_key();
        if (editedColumnsKeys.indexOf(columnKey) == -1) {
            editedColumnsKeys.push();
        }   
    }

    Then, you can access the collection of edited/deleted/added rows from the EditingCore behavior, and iterate over the cells using the keys from the collection:

    var grid = $find("gridid");
    var gridEditingCore = grid.get_behaviors().get_editingCore(); 
    var editedRows = gridEditingCore.get_editedRows();
    
    for (var i=0; i < editedRows.length; i++) {
       var editedRow = editedRows[i];
    
         for (var y=0; y < editedColumnsKeys.ength; y++)) {
             var cellValue = editedRow.get_cellByColumnKey(editedColumnsKeys[y]).get_value();
         }
    
    }

    Please let me know if you have further questions, I will be glad to help.

Reply Children
No Data