SAPUI5 table: unbindRows & destroyColumns cause an error: cannot read property "shouldRender" from undefined

I am using an object Tablefrom the namespace SAPUI5 sap.ui.table:

var oTableOverview = new sap.ui.table.Table ();

In rowSelectionChange, when choosing one row, I fill out another table, let it oTableDetail, which is filled with some data.

When deselecting a row from the first table, I want to clear the contents of the second, and for this I use:

oTableDetail.destroyColumns ();

oTableDetail.unbindRows ();

When deselecting a row, I get the following error:

TableRenderer.js: 6 Uncaught TypeError: Cannot read the 'shouldRender' property from undefined

I found a shouldRenderclass method sap.ui.table.Column, but I'm not sure why in this case the cells would be overwritten.

I also noticed that if I use either oTable.destroyColumns(), or oTable.unbindRows() separately , the error does not appear.

I am using version SAPUI5 "1.38.11".

Could you help me determine why this is happening?

EDIT 1 . A possible workaround would be to use:

oTableDetail.setModel (new file sap.ui.model.json.JSONModel ({}));

oTableDetail.destroyColumns ();

Although I still don't know why the code mentioned above does not work.

EDIT 2 : behavior that I find a bit strange:

trying to add setTimeout how it works (error does not occur):

oTable.destroyColumns ();

setTimeout (function () {oTable.unbindRows ();}, 50);

( ), :

oTable.unbindRows();

setTimeout (function() {oTable.destroyColumns();}, 50);

+4
1
var oTableOverview = new sap.ui.table.Table();
//your model with new dynamic data
var oModel = new sap.ui.model.json.JSONModel(newData);

oTableDetail.setModel(oModel);
//use rerender method which tries to replace
//its DOM reference by re-rendering with new data.
oTableDetail.rerender();

. Rerender .

0

Source: https://habr.com/ru/post/1664262/


All Articles