Forum
17:30
05/08/2012
Right now, when you call getRowData in edit mode, you get the html source of the elements, instead of getting the row values.
I wrote a method that returns the actual values, that calls "getRowDataFromEditMode". You should paste it in jquery.jqGrid.src.js.
getRowDataFromEditMode: function(rowid) {
var success = false;
var $t = this[0], nm, tmp = {}, tmp2 = {}, tmp3 = {}, editable, fr, cv, ind;
if (!$t.grid) { return success; }
ind = $($t).jqGrid("getInd", rowid, true);
if (ind === false) { return success; }
editable = $(ind).attr("editable");
if (editable === "1") {
var cm;
$('td[role="gridcell"]', ind).each(function(i) {
cm = $t.p.colModel[i];
nm = cm.name;
if (nm != 'cb' && nm != 'subgrid' && cm.editable === true && nm != 'rn' && !$(this).hasClass('not-editable-cell')) {
switch (cm.edittype) {
case "checkbox":
var cbv = ["Yes", "No"];
if (cm.editoptions) {
cbv = cm.editoptions.value.split(":");
}
tmp[nm] = $("input", this).is(":checked") ? cbv[0] : cbv[1];
break;
case 'text':
case 'password':
case 'textarea':
case "button":
tmp[nm] = $("input, textarea", this).val();
break;
case 'select':
if (!cm.editoptions.multiple) {
tmp[nm] = $("select option:selected", this).val();
tmp2[nm] = $("select option:selected", this).text();
} else {
var sel = $("select", this), selectedText = [];
tmp[nm] = $(sel).val();
if (tmp[nm]) { tmp[nm] = tmp[nm].join(","); } else { tmp[nm] = ""; }
$("select option:selected", this).each(
function(i, selected) {
selectedText[i] = $(selected).text();
}
);
tmp2[nm] = selectedText.join(",");
}
if (cm.formatter && cm.formatter == 'select') { tmp2 = {}; }
break;
case 'custom':
try {
if (cm.editoptions && $.isFunction(cm.editoptions.custom_value)) {
tmp[nm] = cm.editoptions.custom_value.call($t, $(".customelement", this), 'get');
if (tmp[nm] === undefined) { throw "e2"; }
} else { throw "e1"; }
} catch (e) {
if (e == "e1") { $.jgrid.info_dialog($.jgrid.errors.errcap, "function 'custom_value' " + $.jgrid.edit.msg.nodefined, $.jgrid.edit.bClose); }
if (e == "e2") { $.jgrid.info_dialog($.jgrid.errors.errcap, "function 'custom_value' " + $.jgrid.edit.msg.novalue, $.jgrid.edit.bClose); }
else { $.jgrid.info_dialog($.jgrid.errors.errcap, e.message, $.jgrid.edit.bClose); }
}
break;
}
cv = $.jgrid.checkValues(tmp[nm], i, $t);
if (cv[0] === false) {
cv[1] = tmp[nm] + " " + cv[1];
return false;
}
if ($t.p.autoencode) { tmp[nm] = $.jgrid.htmlEncode(tmp[nm]); }
}
});
}
return tmp;
}
Most Users Ever Online: 715
Currently Online:
12 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