Author Topic: How can I delete a row using a custom img instead of button?  (Read 2981 times)

stoodin

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 85
    • View Profile
How can I delete a row using a custom img instead of button?
« on: March 29, 2014, 01:54:10 am »
Hi guys,
I am trying to delete a row with the img. It works just fine when I copied your example with button as the last column, however when I change button to img only first row gets deleted.
Last Column:
                {title: "", editable: false, sortable: false, render: function (ui) {
                        //return "<button type='button' class='delete_btn'>Delete</button>";
                        return "<img src='images/Remove button.gif' id='imgRmv' width='17' height='17' hspace='0' />";
                    }
                }


        refresh: function () {
            $("#imgRmv")
            .unbind("click")
            .bind("click", function (evt) {
                var $tr = $(this).closest("td"),                 
                    rowIndx = $grid.pqGrid("getRowIndx", { $tr: $tr }).rowIndx;
                alert('RowIndx: ' + rowIndx);
               
                $grid.pqGrid("addClass", { rowIndx: rowIndx, cls: 'pq-row-delete' });
 
                var ans = window.confirm("Are you sure to delete row No " + (rowIndx + 1) + "?");
 
                if (ans) {
                    $grid.pqGrid("deleteRow", { rowIndx: rowIndx, effect: true, complete: function () {
                        $grid.pqGrid("removeClass", { rowIndx: rowIndx, cls: 'pq-row-delete' });
                    }
                    });
                }
                else {
                    $grid.pqGrid("removeClass", { rowIndx: rowIndx, cls: 'pq-row-delete' });
                }
            });
        },
        cellBeforeSave: function (evt, ui) {
            var isValid = $("#grid_array").pqGrid("isValid", ui);
            if (!isValid.valid) {
                evt.preventDefault();
                return false;
            }
        }
    };


stoodin

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 85
    • View Profile
Re: How can I delete a row using a custom img instead of button?
« Reply #1 on: March 29, 2014, 02:24:47 am »
Dont worry. I fixed it.
Thanks a lot