Posted 19 May 2018, 12:42 am EST
grid.itemFormatter = function (panel, r, c, cell) { if (panel.cellType == wijmo.grid.CellType.Cell && panel.columns[c].header == "Action") { cell.innerHTML = "<div align='center'><button id='editRow' type='button' class='button button-grid-edit' >Edit</button> <button id='deleteRow' type='button' class='button button-grid-delete' >X</button></div>"; $(cell).on('click', '#deleteRow', function () { deleteRow(grid.selectedItems[0]) }); $(cell).on('click', '#editRow', editRow); } } var deleteRow = function (item) { console.log('***** deleteRow() ******** count = ' + count); count++; $scope.data.remove(item); }
Using the above functions (stolen from a fiddle somewhere) I have embedded Edit and Delete buttons on each row of my grid. For experimentation, I’ve constrained the delete to only one item (deleteRow(grid.selectedItems[0])). The behavior I’m seeing is that on the first click of a delete button 2 rows are deleted. On the second click of a delete button (will be a different row because the first was deleted) 4 rows are deleted. And the number of times the deleteRow() function is called increases by 2 for each time a delete button is pushed. Help? Thanks!