Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline multi-line edit mode get changed rows, similar getChangeCells #741

Closed
tofdragon opened this issue Nov 18, 2015 · 4 comments
Closed

Comments

@tofdragon
Copy link

After the inline edit multiple lines, call the Save method to save to clientArray, there is no way to get those changes row?

Modify the source code, the code is as follows:

loadComplete:function(){
$(this).jqGrid("initInlineEditData");
}

getChangeRows : function(options){
var $t= this[0];
if (!$t.grid) {
return;
}
var ret=[];
var exInitDatas = $($t).jqGrid("getInitInlineEditData");
$($t.rows).each(function(iRow){
var res = {};
if ($(this).attr("editable") === "0") {

            $('td[role="gridcell"]',this).each( function(iCol) {
                    var cm = $t.p.colModel[iCol];
                    var nm = cm.name;

if (cm.exaddeditdata || (nm !== 'cb' && nm !== 'subgrid' && cm.editable===true && nm !== 'rn' && !$(this).hasClass('not-editable-cell'))) {
try {
res[nm] = $.unformat.call($t,this,{rowId:$t.rows[iRow].id,colModel:cm},iCol);
} catch (e) {
res[nm] = $.jgrid.htmlDecode($(this).html());
}
}
});

            var idname;
            if ($t.p.keyName === false) {
                idname = $t.p.prmNames.id;
            } else {
                idname = $t.p.keyName;
            }
            res[idname] = $t.rows[iRow].id;

            if(exInitDatas != undefined && exInitDatas.length > 0){
                var uniqueKeyField = $($t).jqGrid("getUniqueKeyColumnName");

                for(var initIndex = 0, initLength = exInitDatas.length ; initIndex < initLength; initIndex++){
                    if(exInitDatas[initIndex][uniqueKeyField] === res[uniqueKeyField]){
                        var isEqual = true;
                        $.each(res, function (k, v){
                            if((k !== idname) && exInitDatas[initIndex][k] !== v){
                                isEqual = false;
                                return false;
                            }
                        });

                        if(!isEqual){
                            ret.push(res);
                        }
                        break;
                    }
                    if(initIndex == initLength - 1){
                        ret.push(res);
                    }
                }
            }else{
                ret.push(res);
            }
        }
    });
    return ret;
}

I do not know whether there are better ways and recommendations?

@tofdragon
Copy link
Author

initInlineEditData : function(data){
var $t= this[0];
if(data == undefined){
$($t).data("exInitInlineEditDatas", $($t).jqGrid("getRowData"));
}else{
$($t).data("exInitInlineEditDatas", data);
}
},

@tofdragon tofdragon changed the title Inline multi-line edit mode get changed lines, similar getChangeCells Inline multi-line edit mode get changed rows, similar getChangeCells Nov 19, 2015
@tonytomov
Copy link
Owner

Hello,

After the inline edit multiple lines, call the Save method to save to clientArray, there is no way to get those changes row?

Which changes do you mean?

@tofdragon
Copy link
Author

@tonytomov

Change is actually edit those lines, and the data compared to the previous row, the row has been modified record.

such as:
Before editing:{id:"1", name:"22", age:"21"}, { id:"2", name:"23", age:"23“}

After editing :{id:"1", name:"22", age:"21"}, {id:"2", name:"24", age:"24"},
{id:"new_id", name:"add", age:"2"}

Changes row : id=2,id = new_id

The most basic is to get the actual modified rows. If you provide more advanced methods, similar getChangeCells parameters obtained by the modified row or rows actually modify the column control

@tonytomov
Copy link
Owner

HEllo,

You can compare the data with the savedRow grid parameter and serializeRowData

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants