tags:

views:

173

answers:

2

Hello all,

I'm having a problem updating a row after an inline edit. My ColModel is:

colModel: [
    { name: 'Email', index: 'Email', editable: true },
    { name: 'ReferenceEmail', index: 'ReferenceEmail', editable: true },
      // hidden: true, editable: true, editrules: { edithidden: true}
    { name: 'Title', index: 'Title', editable: true, edittype: "select",
      editoptions: { value: "Mr:Mr;Mrs:Mrs;Ms:Ms;Doctor:Doctor;Sir:Sir"} },
    { name: 'Forename', index: 'Forename', editable: true },
    { name: 'Surname', index: 'Surname', editable: true },
    { name: 'Study_Manager', index: 'Study_Manager', editable: true,
      edittype: "select", editoptions: { value: "True:True;False:False"} }
]

I plan to set the referenceemail col value = the new edited email value, so i have:

ondblClickRow: function (id, ri, ci) {
            lastSelUser = id;
            $("#UserGrid").editRow(id, true, false, reload);
        }

which in turn calls reload onsuccess of the edit,

function reload(result) {
    var cell = $("#UserGrid").getCell(lastSelUser, 'Email');
    var newEmail = $(cell).val();
    $("#UserGrid").saveRow(lastSelUser, false);

    $("#UserGrid").setRowData(lastSelUser, { ReferenceEmail: newEmail });


    var ref = $("#UserGrid").getCell(lastSelUser, 'ReferenceEmail');
    alert($(cell).val());
    alert($(ref).val());

}

Now my reference email doesnt get updated - the alert of the cell value returns correctly, but the alert of the ref(referenceemail) value is undefined and i've checked that the id is infact correct.

I've tried putting the saverow after the setRowData, but that makes no difference to the outcome.

Once again, I greatly appreciate any and all insight into the problem.

Regards, Byron Cobb

A: 

A partial solution has been found for anyone wondering. The jqGrid editRow accepts the following paramaters:

jQuery("#grid_id").editRow(rowid, keys, oneditfunc, succesfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc

.setRowData doesnt seem to work in the succesfunc, but it does work in aftersavefunc, so my new call is $("#UserGrid").editRow(id, true, false, false, false, false, reload); instead of $("#UserGrid").editRow(id, true, false, reload);

Byron Cobb
+1  A: 

I am not sure that I understood correctly your question.

It seems to me, that use should use aftersavefunc parameter of editRow instead of succesfunc (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#editrow). The event aftersavefunc will be called after the data will be saved in the jqGrid. The event succesfunc will be called only after $.ajax (no local data editing support) and immediately after the request completed before the data are saved in the grid.

The aftersavefunc event receive as parameters rowid - id of modified row, and res - response from the server. So if the ReferenceEmail field can be set by the server based on Email value you can use the results. To set ReferenceEmail field you can just use

$("#UserGrid").jqGrid('setCell',rowid,'ReferenceEmail', data);

where data is the new value of ReferenceEmail.

Oleg