hello again
sorry for double posting, but i really need help with this.
i think, i've found a bug on scrollview js plugin.
here is the error message:
ypeError: rowData is undefined
var value = rowData[field]; // the field value
when i started create new row, but it's really disgusting, because sometimes when i create new row, it's isn;t thrown that error message.
it's like unstable i think.
here how i start creating new row:
function new_row(dg){
if (state.op == "edit"){
$.messager.alert('Warning', 'There are current record being edited. You can not editing different record in the same time.');
return false;
}
// AJAX REQUEST
$.get(init_url,function(data){
var row = dg.datagrid('getSelected');
if (row){
var index = dg.datagrid('getRowIndex', row);
}else{
index = 0;
}
dg.datagrid('insertRow', {
index: index,
row: {
country_id: data.val,
status: 0
}
});
state.row = "new_row";
dg.datagrid('selectRow', index);
dg.datagrid('beginEdit', index);
},'json');
}
here is event on datagrid that have a relations with that function:
onBeforeEdit: function(rowIndex, rowData){
rowData.editing = true;
updateActions(rowIndex, $list_data);
loadLinkbutton(this);
state.op = "edit";
},
onAfterEdit: function(rowIndex, rowData, changes){
rowData.editing = false; //custom 20150102
getChange($list_data, url_crud_row, this, state, rowIndex, rowData);
},
onCancelEdit: function(rowIndex, rowData){
rowData.editing = false;
updateActions(rowIndex, $list_data);
loadLinkbutton(this);
state.op = "show";
},
code updateactions:
function updateActions(index, dg) {
dg.datagrid('updateRow', {
index: index,
row: {
}
});
}
function getchanges:
function getChange(dg, url_data, obj, state, rowIndex, rowData) {
if (dg.datagrid('getChanges').length) {
var inserted = dg.datagrid('getChanges', 'inserted');
var updated = dg.datagrid('getChanges', 'updated');
var deleted = dg.datagrid('getChanges', 'deleted');
var effectRow = new Object();
if (inserted.length) {
effectRow['inserted'] = JSON.stringify(inserted);
}
if (updated.length) {
effectRow['updated'] = JSON.stringify(updated);
}
if (deleted.length) {
effectRow['deleted'] = JSON.stringify(deleted);
}
}
if (effectRow == null) {
if (state.row == 'new_row') {
updateDataRow(rowIndex, obj);
} else {
updateActions(rowIndex, dg);
loadLinkbutton(obj);
}
state.op = 'show';
state.row = '';
return false;
}
var data = $.ajax({
url: url_data,
type: 'POST',
data: {
row_data: effectRow
},
dataType: 'json'
}).done(function (data) {
if (data.msg == 'OK') {
dg.datagrid('acceptChanges');
if (state.row == 'new_row') {
state.id = data.id
updateDataRow(rowIndex, obj);
} else if (state.op == 'edit'){
state.id = data.id
updateDataRow(rowIndex, obj);
updateActions(rowIndex, dg);
loadLinkbutton(obj);
}else{
updateActions(rowIndex, dg);
loadLinkbutton(obj);
}
state.op = 'show';
state.row = '';
} else {
if (state.row == 'new_row') {
dg.datagrid('rejectChanges');
} else if (state.op == 'edit') {
dg.datagrid('beginEdit', rowIndex);
} else {
dg.datagrid('rejectChanges');
}
$.messager.alert('Info', data.msg, 'info');
}
}).fail(function (request, status, error) {
$.messager.alert('Info', request.responseText);
});
}
function loadlinkbutton:
function loadLinkbutton(obj) {
$(obj).datagrid('getPanel').find('a.easyui-linkbutton').linkbutton();
}
please help me to solve this issue, it really disgusting.
nb: i already use the latest scrollview js and patch for version 1.4
many thanks for your answer.