0

I am trying to edit, insert and delete inline in jqGrid and successfully do so for insert and edit BUT not for delete. I read about using 'clientArray' and it does the trick as I mentioned for the edit, but not for the delete. When the delete function is called, the message for deletion pops, but when clicking on delete, I get the message: "No url is set".

What am I doing wrong? These are the functions that get called when clicking on the the appropriate buttons.

function _deleteLine(rowId) {
    var id = rowId;
    if (_.isNumber(id) === false) {
        id = rowId.id;
    }

    self.$grid.delGridRow(id, false, 'clientArray');
}

function _editLine(rowId) {
    var id = rowId;
    if (_.isNumber(id) === false) {
        id = rowId.id;
    }
    self.$grid.jqGrid("editRow", id, true);
    _toggleActionButtons(true, id);
}

function _saveLine(rowId) {
    var defer = $.Deferred();

    var id = rowId;
    if (_.isNumber(id) === false) {
        id = rowId.id;
    }
    self.$grid.saveRow(id, false, 'clientArray');
    toggleActionButtons(false, id);
    return defer.promise();
}

Update:

After changing the delete function to the following I was able to remove the item, however, to modal doesn't close. I looked at this and followed it but wasn't able to solve:

function _deleteLine(rowId){
options.processing = true;
            var grid_id = $.jgrid.jqID(this.p.id);
            self.$grid.jqGrid("delRowData", rowid);
            $.jgrid.hideModal("#delhd" + grid_id, {
                gb: "#gbox_" + grid_id,
                jqm: true
            });
}
Rotem B
  • 1,327
  • 1
  • 15
  • 20
  • Which version of jqGrid you use (can use) and from which fork of jqGrid ([free jqGrid](https://github.com/free-jqgrid/jqGrid), commercial [Guriddo jqGrid JS](http://guriddo.net/?page_id=103334) or an old jqGrid in version <=4.7)? I'm not sure why you need to write a wrapper to every method of jqGrid (`delGridRow`, `editRow`, `saveRow`). I suppose that the calls of `toggleActionButtons` and `_toggleActionButtons` are unneeded too if you would use the current versions of free jqGrid. – Oleg Feb 08 '17 at 17:26
  • You are right to ask for my version of course.... 4.6.0 – Rotem B Feb 08 '17 at 17:34

1 Answers1

1

jqGrid 4.6 is 3 yeas old. It was the last version, which don't support delGridRow for local data. Many years ago I posted the workaround, which describe how one can use the method of form editing to delete line of the local grid. Later I posted another answer, which shows how to use other form editing methods for editing of local rows.

In general I would recommend to update to the latest version (4.13.6) of free jqGrid, the fork of jqGrid, which I develop starting with the end 2014. Free jqGrid is compatible to jqGrid 4.6, but many new features allows to simplify the usage of jqGrid. For example, you can use formatter: "actions", inlineNav and call editRow directly. All buttons (inline action buttons and the buttons of navigator menu) will be automatically be hidden/visible or enabled/disabled after starting/ending of editing. No additional calls to show/hide the buttons is required. Try the demo, for example.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thanks Oleg for your reply. I looked at your post and updated my function. I have a problem similar to the one you helped solve before. I can remove it but to modal won't disappear. What am I doing wrong? I used "delhd"+gridId because I saw that this was the element id. – Rotem B Feb 09 '17 at 06:01