Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Possible bug with celledit mode and value returned from onbeforeSaveCell while in local edit mode
15/07/2010
18:12
Avatar
williamfjordan
Member
Members
Forum Posts: 3
Member Since:
13/05/2010
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information