I have an igGrid that allows row updating. I need to be able to call a method and get the current row values when the user starts to edit to the row, yet for some reason the 'editRowStarted' event does not return a reference to the values of the row. 'editRowEnded' is a good example of what I want - it allows you to access the values of a row simply by calling 'ui.values' on the ui parameter of the function. I know that 'editRowStarted' does return the 'rowID', but I have not been able to use that to get the values from a row. I'm sure this is a simple fix that I am overlooking.
I was able to get the values, but the way it was done is not preferred. I don't want to have to pick apart my document to get the values I need. There should be (and probably is) a way to return a JSON object, or at least some sort of structured data.
var row = $('.selector').igGrid('rowById', ui.rowID)[0]; var dataID = row.getAttribute('data-id'); var cellValue = $('.selector_table tr[data-id="'+dataID+'"] td[aria-describedby="selector_table_ColumnTitle"]').text();
P.s. the code editor on here is awful. The cursor does not insert or delete characters at the position clicked and shown....
Hello Pete,
Thank you posting in our community.
Your observation is correct, at this point cell values are not available via the arguments of editRowStarted event. However, I can suggest a few options for achieving your requirement.Using getCellvalue method,which retrieves the value by its rowID and columnKey. Since this method works cell by cell in order to get all cell values you will have to loop all the columns (or just the one needed for your scenario). For example: editRowStarted: function(evt, ui){ var grid = $("#grid"), colKey; gridCols = grid.igGrid("option", "columns"); $.each(gridCols, function(index, val){ alert("Value of column " + gridCols[index].headerText + " is: " + grid.igGrid("getCellValue", ui.rowID,gridCols [index].key ) ); }); },This code will loop trough all column in the columns collection and will show their values in an alert box.Using editCellStarted event. This event is fired after cell editing begins and before editRowStared event is fired. Basically, the event is going to be fired once for every cell in the row. In this event, via the ui event argument the cell value is available. For example: editCellStarted: function(evt, ui){ var cellValue = ui.vakue }Please let me know if you need any further assistance with this matter.