Author Topic: T[c] is not a function error giving when delete row  (Read 500 times)

sshede

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 41
    • View Profile
T[c] is not a function error giving when delete row
« on: April 04, 2023, 11:48:50 am »
Hi,
I try delete row  but giving error.
i am usging pro 7.6

error -  T[c] is not a function

{ title: "Delete", dataIndx: "Delete", editable: false,  width: 70, sortable: false,  render: function (ui) {
                                                    return "<img src='../images/delete-2.png' height='10px' class='deletRow'  title='Delete Row' >"},
                                                    postRender: function (ui) {
                                                        var grid = this;
                                                        grid.deleteRow({ rowIndx: ui.rowIndx });
                                                }
                                            },

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: T[c] is not a function error giving when delete row
« Reply #1 on: April 04, 2023, 12:36:32 pm »
You can't call the deleteRow directly from postRender callback.

column.postRender is used to attach event handlers to cells.

Code: [Select]
postRender: function (ui) {

    var rowIndx = ui.rowIndx,
        grid = this,
        $cell = grid.getCell(ui);

    $cell.find("img")
    .on("click", function () {
        grid.addClass({ rowIndx: ui.rowIndx, cls: 'pq-row-delete' });
        setTimeout(function () {
            var ans = window.confirm("Are you sure to delete row No " + (rowIndx + 1) + "?");
            grid.removeClass({ rowIndx: rowIndx, cls: 'pq-row-delete' });
            if (ans) {
                grid.deleteRow({ rowIndx: rowIndx });
            }
        })
    });
}

Example: https://paramquery.com/pro/demos/editing_batch