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
210
ig grid - When clicking on button located in unbound column, iggridupdatingeditrowended is also firing
posted

Relevant problem #1

Grid update mode is row.

The default delete hover buttons are not actually placed in the row but it is an element that "attempts" to absolutely position it after the row end. This of course fails and the delete button is broken. 

Problem #2 

Note* I have used jQuery to remove the default non-working delete hover button.

So to fix the above I have added an unbound row which I populate using a formula to place a Delete button within the grid. First issue I faced was with the Delete button when clicking that it causes the whole row to become edited. This is not ideal, because then it blocks the Delete button click. This is fixed by disabling the column field as an editable field. 


// Prevents the Delete column being editable
$(document)
.delegate("#igGrid",
"iggridupdatingeditcellstarting",
function (evt, ui) {
  if (ui.columnKey === "Delete") {
      return false;
  }
   return true;
});

This is fine but not ideal as when I click the Delete button the rest of the row is still going into edit mode. So here comes the final problem and the one this topic is trying to address. When I press the Delete button, my own function to delete the row fires but then also the "iggridupdatingeditrowended" fires. This causes 2 transactions to occur, 1st to delete the row and then 2nd to update the non-existent row. When in the MVC controller I just process the delete row the Editrowended is re-added the deleted row back to the iggrid.

Is there a fix and perhaps a more elegant solution to my problem? Is there no solution and must I use some external dialogs/views/controls outside of igniteui to edit/delete the rows?

Parents
  • 17590
    Offline posted

    Hello Jagdip,

    By design the delete button position is calculated according to the igGrid scroll container.

    In order to accomplish repositioning of the "Delete" button the showDeleteButton function can be modified to change the position of the button. In your case, since you would like to position the button in the last cell "left" css property should be modified. Calculations should take row width, and the button width under consideration. For example:

    var origPositioning = $("#grid1").data("igGridUpdating").showDeleteButtonFor;
       $("#grid1").data("igGridUpdating").showDeleteButtonFor = function (row) {
        origPositioning.apply($("#grid1").data("igGridUpdating"), [row]);
        var db = $("#" + this.grid.id() + "_updating_deletehover");
        // reposition
        db.css("left", row.outerWidth() - db.outerWidth() - 5);
       };

    I am attaching a small sample for your reference. Please test it on your side and feel free to contact me if you have any additional questions regarding this matter.

    igGridRepositionDeleteButton.zip
Reply Children