OpenUI5 1.38 附加事件滚动条



从最新版本更新(从OpenUI5 1.36.12到OpenUI5 1.38.4)以下代码不再工作:

var myTable = new sap.ui.table.Table();
myTable ._oVSb.attachScroll(function() { 
   colorTheTableRows();
})

我正在使用"attachScroll"事件,以便使用特定逻辑为表行着色。自上次 openui5 版本更新以来,我在控制台中收到此错误:

Uncaught TypeError: Cannot read property 'attachScroll' of undefined

我试图调试问题,似乎对象_oVSb已从sap.ui.table.Table中删除。

我的最终目标是根据内容用不同的颜色绘制行......还有其他方法可以使用此功能吗?

谢谢

甚至我也希望这个事件如何来到这个线程。 我尝试了@Dopedev解决方案它不起作用,然后我更改了一下,如下所示

              $("#<tablid>-vsb").scroll(function() { 
                 console.log("Table is scrolled")
              });

而不是获取 tbody 获取表 ID-VSB 并附加滚动函数

你仍然可以使用 jQuery 的 .scroll() 获取表的滚动事件。

onAfterRendering: function(){
    //Register handler for scroll event
    $("tbody").scroll(function(){
        // your stuff
    });
}

演示

我知道

之前的一篇文章已经被标记为"正确"答案,但它对我不起作用,所以我想我会发布我的工作解决方案,因为它可能对其他人有所帮助。以下代码将有效地"附加"到 1.38 中表的垂直滚动事件:

    onAfterRendering: function() {
        if (this.firstTime) { //You only want to override this once
            var oTable = this.getView().byId("<YOUR_ID_HERE>");
            //Get a reference to whatever your custom handler is
            var oHandler = this.handleScroll;
            //Store a reference to the default handler method
            var oVScroll = oTable.onvscroll;
            oTable.origVScrollHandler = oVScroll;
            oTable.onvscroll = function(i) {
                //Call the 'default' UI5 handler
                oTable.origVScrollHandler(i);
                //Call your handler function, or whatever else you want to do
                oHandler();
            };
            this.firstTime = false;
        }
    },

var myTable = new sap.ui.table.Table("myTable");

渲染后:

sap.ui.getCore().byId("myTable-vsb").attachScroll(function() { colorTheTableRows(); })

最新更新