Forum
15:14
10/08/2009
Hello Tony,
one can see that the line of inlineNav uses always editParams options instead of addParams.addRowParams in case of adding new row. For example if one want to use mtype: "POST" for adding and mtype: "PUT" for editing and to use different url for Add and Edit operation the code will be about the following
// … some jqGrid parameters
ajaxRowOptions: { contentType: "application/json", async: true }
}).jqGrid("navGrid", "#pager", { edit: false, add: false, del: false, search: false })
.jqGrid("inlineNav", "#pager", {
addParams: {
addRowParams: {
mtype: "POST",
url: "Service.svc/AddUser",
keys: true,
aftersavefunc: function(rowid, response) {
var newId = $.parseJSON(response.responseText),
$self = $(this),
idPrefix = $self.jqGrid("getGridParam", "idPrefix", newId),
selrow = $self.jqGrid("getGridParam", "selrow", newId),
selArrayRow = $self.jqGrid("getGridParam", "selarrrow", newId),
oldId = $.jgrid.stripPref(idPrefix, rowid),
dataIndex = $self.jqGrid("getGridParam", "_index", newId),
i;
// update id in the _index
if (dataIndex[oldId] !== undefined) {
dataIndex[newId] = dataIndex[oldId];
delete dataIndex[oldId];
}
// update id in <tr>
$("#" + $.jgrid.jqID(rowid)).attr("id", idPrefix + newId);
// update id of selected row
if (selrow === rowid) {
$self.jqGrid("setGridParam", { selrow: idPrefix + newId });
}
// update id in case of usage multiselect: true option
if ($.isArray(selArrayRow)) {
i = $.inArray(rowid, selArrayRow);
if (i >= 0) {
selArrayRow[i] = idPrefix + newId;
}
}
// the next line is required if we use ajaxRowOptions: { async: true }
$self.jqGrid("showAddEditButtons");
}
}
},
editParams: { mtype: "PUT", keys: true, url: "Service.svc/EditUser" }
});
If one uses Enter key to save the row then correct options addParams.addRowParams will be used, but in case of usage "Save" button the wrong options (wrong url, wrong mtype etc) will be used.
I posted relatively long code of aftersavefunc to show another problem: changing the id of new added row. The same problem exist in editGridRow too, but first it is not so important because reloadAfterSubmit: true is default option of form editing, seconds because the code of editGridRow contains the part (see here) which uses the id returned from the server.
One more problem: one have to call showAddEditButtons manually in case of usage ajaxRowOptions: { async: true }.
Probably we consider to include the part of renaming of id inside of main code of inline editing module of jqGrid? For example one could allow that aftersavefunc returns the newid (without idPrefix). In the case the code of aftersavefunc could be reduced to
return $.parseJSON(response.responseText);
}
In the case all renaming operations could do saveRow method itself.
Best regards
Oleg
12:48
Moderators
30/10/2007
Thanks Oleg.
Just fixed this to use the appropriate parameters
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
10 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66