0

I have a jqGrid table, the same one from this problem, which I load with information from the server, but I store locally, so I have the option datatype set to 'local'.

I also set the delete button to use this function. It has to delete the row from database and from the grid.

var grid = $('#grid');

    grid.jqGrid('navButtonAdd', '#pager', 
    {
        caption: "",
        buttonicon: "ui-icon-trash",
        position: "first",
        title: "Delete",
        cursor: "pointer",
        id: 'del_list',

        onClickButton: function del(event) {
            var rowID = grid.jqGrid('getGridParam', 'selrow');
            if (rowID === null) {
                $('<div title="Error"><p>Error</p></div>').dialog({
                    modal: true,
                    width: 350,
                    buttons: {Aceptar: function () {
                        $(this).dialog("close");
                    }},
                    dialogClass: "ui-jqdialog"
                });
            }
            else {
                grid.jqGrid('delGridRow', rowID, 
                {
                    width: 400,
                    delicon: [true, "left", "ui-icon-cancel"],
                    cancelicon: [true, "left", "ui-icon-close"],
                    beforeShowForm: function (form) {
                        SetFormsSize('#delmodtGrid');
                    },
                    caption: "Delete",
                    msg: "asdasdasd",
                    onclickSubmit: function (params, postdata) { 

                        var code = parseInt(grid.find('tr:eq(' + rowID + ')').find('td:eq(0)').text());
                        var ver = parseInt(grid.find('tr:eq(' + rowID + ')').find('td:eq(2)').text());

                        var add_data = {ProjectID: code, VersionID: ver};
                        return add_data;
                    },
                    afterComplete: function (response, postdata) {
                        if (response.responseText === "Success") {
                            $('<div title=""><p>asdasdas</p></div>').dialog({
                                modal: true,
                                width: 400,
                                buttons: {Aceptar: function () {
                                    $(this).dialog("close");
                                }},
                                dialogClass: "ui-jqdialog"
                            });
                        }
                        else {
                            $('<div title="Error: ' + response.responseText + '"><p>asdasdasd</p></div>').dialog({
                                modal: true,
                                width: 400,
                                buttons: {Aceptar: function () {
                                    $(this).dialog("close");
                                }},
                                dialogClass: "ui-jqdialog"
                            });
                        }                    
                    }
                });
            }            
        }
    });

I have an action server-side that handles the deletion in the database. I have a try-catch sentence for it, and it doesn't throw any exceptions. With Firebug, I get the POST request is successful, along with the response (this I got adding an afterSubmit option function and checking postdata). So the problem, I belive, lies with the jqGrid's settings.

After it goes through the server-side code (and, when I set it, after the afterSubmit event is fired), this is the error I get (translated from Spanish):

Runtime error Microsoft JScript: Object doesn't accept property or method 'split'

It affects jquery.jqGrid.min.js at line 331, in the sentences

if(d[e.p.id].reloadAfterSubmit&&e.p.datatype!="local")
   a(e).trigger("reloadGrid");
else{
   var A=[];
   A=H.split(",");
   ...
}

from the complete function. The part that generates the error is the second sentence of the else clause.

Community
  • 1
  • 1
Heathcliff
  • 3,048
  • 4
  • 25
  • 44

1 Answers1

0

Nevermind, the solution was here: jqgrid error when deleting row, that directs to the answer here: http://www.trirand.com/blog/?page_id=393/bugs/4-2-0-g-split-is-not-a-function-error/

Community
  • 1
  • 1
Heathcliff
  • 3,048
  • 4
  • 25
  • 44