Skip to Content
0
May 31, 2019 at 07:58 PM

sap.ui.table.Table. Duplicate row after deleting a record

571 Views Last edit May 31, 2019 at 08:01 PM 2 rev

Hi community,

I've been struggling with an issue for a little bit now and Im running out of options... Hope I can get some answers here :)

I have a very simple table to manage links to third party websites, just like this:

VisibleRowCount for this table is 3.

With 3 entries or less (no scrollbar) removing or adding a link would work just fine, my model refreshes after update so my changes are reflected on the table just like it should.

The issue comes when I have 4 or more records, and hence a scrollbar in my screen...

After adding a 4th link to my table, I see two different kind of behaviors:

1. As long as I am displaying the top row (Test 1, scrollbar is all the way up), if I delete Test1, Test2 or Test3, after the model refreshes I see how the scrollbar dissapears and the 4th row now becomes the 3rd. Everything just fine:

Test 4 is the 4th row, not visible right now be cause the scrollbar is all the way up.

After deleting:

2. If, on the contrary, if my scrollbar is all the way down (or down at any point, if I had a lot of rows in my table), then the behavior is the following:

Now after deleting Test4 for instance:

You can see that Test4 is gone and Test5 has been moved up, so all rows are in display right now, however the scrollbar is still there. If I scroll up that makes another call to my backend that return the correct number of rows, however, what I get in my screen is a 4th row for Test5, so I have a duplicate last row.

If I sort by any column or, close and open my app, or insert another record then this row goes away.

Im at a loss here really, I dont see what could be wrong. This is a very easy app, there is no complex logic on managing the model or any weird stuff that could be interfering. Here are the important parts:

// This is my model instantation. And Im not doing any extra model refresh after oData operation.
// Row binding is done on the XML view
// The model is bound to the view, instead of to the table directly (although I have tried)
this.oModel = new ODataModel(menu.util.utils.getSystemUrl(this.SERVICE_PATH + this.SERVICE_NAME), {
		    json : true,
		    refreshAfterChange : true,
		    loadMetadataAsync : true,
		    skipMetadataAnnotationParsing : true,
		  });
// Im using submitChanges to insert my new records
_submitChanges : function() {
		  var that = this;
		  var sMessages;

		  if (this.oModel.hasPendingChanges()) {
			  this.oModel.submitChanges({

...

// And remove to delete
_delete : function(oData) {
		  var that = this;
		  this.oModel.remove(this.ENTITYSET_NAME + "(LinkId='" + oData.LinkId + "')", {
...

I could be missing something really stupid here... but I dont see it!

I can add more details if needed.

EDIT: I forgot to add that all my backend calls work as expected, and the data is maintained properly. Also I disabled the cache in the oData calls as part of my troubleshooting.

Thanks in advance!

Attachments

1.png (6.7 kB)
2.png (7.3 kB)
3.png (7.1 kB)
4.png (7.7 kB)
5.png (7.3 kB)
6.png (7.9 kB)