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

Cell editing with remote data and a low latency server does not update the table properly #1011

Open
eCitiz opened this issue May 10, 2022 · 3 comments

Comments

@eCitiz
Copy link

eCitiz commented May 10, 2022

An example project can be found here : https://jsfiddle.net/nducoin/ue0kyxtz/4/

Editing multiple cells of a table with remote data does not work properly when the server does not respond quickly enough.

I noticed the following when sending multiple edit request on different cells before their processing by the server:

  • The requests received by the server are corrupts: The "id" is always the same when editing different cells and the "value" is not always the right value
  • The processing of the server's response does not update the right cell with the right value: the first cell edited is cleared and the following cells are either cleared or display a wrong value

The editing of the same cell multiple times does not work properly either.

I managed to fix this bug in the version 5.5.4 by updating the "saveCell" function by using the parameter "iRow" instead of the value "$t.p.savedRow[fr].rowId" and by removing the right element in the "$t.p.savedRow" array:

...
// var trow = $($t).jqGrid("getGridRowById", $t.p.savedRow[0].rowId),
var trow = $($t).jqGrid("getGridRowById", iRow),
...
// postdata[idname] = $.jgrid.stripPref($t.p.idPrefix, $t.p.savedRow[fr].rowId);
postdata[idname] = $.jgrid.stripPref($t.p.idPrefix, iRow);
...
$(cc).empty();
//$($t).jqGrid("setCell",$t.p.savedRow[fr].rowId, iCol, v2, false, false, true);
$($t).jqGrid("setCell",iRow, iCol, v2, false, false, true);
cc = $('td', trow).eq( iCol );
$(cc).addClass("dirty-cell");
$(trow).addClass("edited");
// $($t).triggerHandler("jqGridAfterSaveCell", [$t.p.savedRow[fr].rowId, nm, v, iRow, iCol]);
$($t).triggerHandler("jqGridAfterSaveCell", [iRow, nm, v, iRow, iCol]);
if ($.jgrid.isFunction($t.p.afterSaveCell)) {
	// $t.p.afterSaveCell.call($t, $t.p.savedRow[fr].rowId, nm, v, iRow,iCol);
	$t.p.afterSaveCell.call($t, iRow, nm, v, iRow,iCol);
}
// Adding a processing for removing the right element in the array "$t.p.savedRow"
var indexOfSavedRowBeingProcessed = -1;
for (var savedRowIterator of $t.p.savedRow)
{
	if (savedRowIterator.rowId == iRow && savedRowIterator.ic == iCol)
	{
		indexOfSavedRowBeingProcessed = $t.p.savedRow.indexOf(savedRowIterator);
	}
}
if (indexOfSavedRowBeingProcessed !== -1) 
{
	$t.p.savedRow.splice(indexOfSavedRowBeingProcessed, 1);
}
// $t.p.savedRow.splice(0,1);
...
@tonytomov
Copy link
Owner

tonytomov commented May 16, 2022

Hello,

Apologize for the late answer. The problem lie in the how the ajax is using. We use ajax complete instead of success which causes this delay. We plan to rewrite this code to use ajax success, but this is not a trivial task, because of the existing users.

Using the iRow in place of rowId is not a good solution for all existing users.

Best Regards

@eCitiz
Copy link
Author

eCitiz commented Nov 10, 2023

Hello,

Do you know when this problem could be fixed?

Best regards

@tonytomov
Copy link
Owner

Hello I have fixed the problem. Fortunately the success contain [jqXHR] object too.
See here: 67f46f5

Please test the fix and let me if it is ok for you.

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