Forum
18:12
13/05/2010
I am using the 3.7.2 version
From the documentation on beforeSaveCell:
applies only to a cell that is editable; this event fires before validation of values if any. This event can return the new value which value can replace the edited one
beforeSaveCell : function(rowid,celname,value,iRow,iCol) {
if( some_condition )
{ return “new value”; }
}
The value will be replaced with “new value”
From grid.celledit.js in the saveCell function:
[skipped some code]
case "select":
if(!cm.editoptions.multiple) {
v = $("#"+iRow+"_"+nmjq+">option:selected",$t.rows[iRow]).val();
v2 = $("#"+iRow+"_"+nmjq+">option:selected",$t.rows[iRow]).text();
} else {
var sel = $("#"+iRow+"_"+nmjq,$t.rows[iRow]), selectedText = [];
v = $(sel).val();
if(v) { v.join(",");} else { v=""; }
$("option:selected",sel).each(
function(i,selected){
selectedText[i] = $(selected).text();
}
);
v2 = selectedText.join(",");
}
if(cm.formatter) { v2 = v; }
break;
[skipped some code]
if ($.isFunction($t.p.beforeSaveCell)) {
var vv = $t.p.beforeSaveCell($t.rows[iRow].id,nm, v, iRow,iCol);
if (vv) {v = vv;}
}
[skipped some code]
if ($t.p.cellsubmit == 'clientArray') {
$(cc).empty();
$($t).jqGrid("setCell",$t.rows[iRow].id,iCol, v2, false, false, true);
$(cc).addClass("dirty-cell");
$($t.rows[iRow]).addClass("edited");
if ($.isFunction($t.p.afterSaveCell)) {
$t.p.afterSaveCell($t.rows[iRow].id,nm, v, iRow,iCol);
}
$t.p.savedRow.splice(0,1);
}
I am in the callback event for a cell with an edittype = 'select' and a custom formatter.
On the red bold line above, the code is calling setCell with v2 which is the original value from the select and not v which is the value from my callback function.
So the return from the beforeSaveCell callback is being ignored.
I think v2 needs to be replaced with the value in v in the call to setCell.
Most Users Ever Online: 715
Currently Online:
29 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