Hi,
In the event CellValueChanging (EditingCore EditingClientEvents-CellValueChanging and EditingClientEvents CellValueChanging), I want to verify if the user is entering a value that is already in the same column of the same group of child rows (child rows Under the same parent wor) or the parents rows, depending if he is changing the value for a child row or a parent row. If the value already exist, i want to cancel the CellValueChanging event (i already do it for other reasons in the same event, for example if value >= 900). This works already for any other validations when the user enters a value in an existing row or a new row as parent row or child row (i didn't have to iterate the other rows yet). I just can't iterate the throught the rows of the same group of rows and get the other values of the column to compare them with the value the user has just entered in the cell. Is there a way to do it and cancel the event (or at least not add this value in the grid because it can be saved in the database on postback)?
Thank you.
What rows is your code iterating throught to compare if the value already exist? (using grid.get_rows)
-all the rows of the WebHierarchicalDataGrid?
-only the parent rows?
-only the rows in the same GridView/RowIsland than the cell the user is editing?
I need to iterate only the rows in the same GridView/RowIsland.
And what about editing the cell of a new row (RowAdding row/AddedRow at the bottom of the rows of a level). I want to iterate throught the rows of the GridView/RowIsland where the new row will be added to compare if value exists. Is that what your code does?
Hello Danjut,
Thank you for contacting Infragistics Developer Support!
You can use the sender argument from your handler for CellValueChanging which will be the grid and cancel the event.
function WebHierarchicalDataGrid_Editing_CellValueChanging(sender, eventArgs) { var cellNewValue = eventArgs.get_newValue(); var columnKey = eventArgs.get_cell().get_column().get_key() if (isCellAlreadyInGrid(cellNewValue, columnKey, sender)) { eventArgs.set_cancel(true); } } function isCellAlreadyInGrid(cellNewValue, columnKey, grid) { var rows = grid.get_rows(); for (var i = 0; i < rows.get_length(); i++) { var row = grid.get_rows().get_row(i); var cell = row.get_cellByColumnKey(columnKey); if (cellNewValue == cell.get_value()) { alert(cellNewValue + " already exists!"); return true; } } return false; }
Let me know if you need further assistance.
I have even tried with the selected row but i cant get the first selected row as usual to get its grid to iterate rows when i'm in CellValueChanging.
var selectedRows = grid.get_gridView().get_behaviors().get_selection().get_selectedRows(); //works
var selectedRow0 = selectedRows.getItem(0); //doesn't work