javascriptsapui5treetable

Trigger function after update complete


How can I perform the functions order, when the update function works with xsodata?! So far my problem is with updating the tree table and then open the previous rows that has been opened before update. I am using the setTimeout function but i know it is actually not the answer to this problem.

tEvents.unbindAggregation("rows");
tEvents.bindAggregation("rows",{
    path: "events>/prg_years(ID_SCENARIO=" + filterKRVR.scenario + ",I_YEAR=" + filterKRVR.year + "m)" + "/HisGTO",
    parameters: {
        navigation: {
            'prg_gto':  "HisPIPE",
            'prg_pipe': "HisKS",
            'prg_ks':   "HisLK"
        },
    }
}); 

tEvents.getModel('events').refresh();

        

if(bookmark.gto!==null){
    var that = this;
    setTimeout(function(){
        var t = that.getView().byId('eventsKRVR');
        t.expand(bookmark.gto);
    },800)
}
if(bookmark.pipe!==null){
    var that = this;
    setTimeout(function(){
        var t = that.getView().byId('eventsKRVR');
        t.expand(bookmark.pipe);
    },1500)
}
if(bookmark.ks!==null){
    var that = this;
    setTimeout(function(){
        var t = that.getView().byId('eventsKRVR');
        t.expand(bookmark.ks);
    },2500)
}

Does anyone have any suggestions?


Solution

  • i managed to solve this question by attachRequestCompleted.

    tEvents.getModel('events').attachRequestCompleted(function (oEvent) {
                        var url = oEvent.mParameters.url;
                        if(url.indexOf('prg_years') >= 0){
                            setTimeout(function(){
                                that.doRefresh();
                                setTimeout(function(){
                                    tEvents.expand(bookmark.gto);
                                },100)
                            },100)
                        }else if(url.indexOf('prg_gto') >= 0){
                            setTimeout(function(){
                                that.doRefresh();
                                setTimeout(function(){
                                    tEvents.expand(bookmark.pipe);
                                },100)
                            },100)
                        }else if(url.indexOf('prg_pipe') >= 0){
                            setTimeout(function(){
                                that.doRefresh();
                                setTimeout(function(){
                                    tEvents.expand(bookmark.ks);
                                },100)
                            },100)
                        }else if(url.indexOf('prg_ks') >= 0){
                            setTimeout(function(){
                                that.doRefresh();
                                setTimeout(function(){
                                    $('.sapUiScrollBar div').scrollTop(32*bookmark.lk-64);
                                },100)
                            },1000)
                        }
                    });
    

    also made a hack for table refresh, because sometimes there is a problem with rendering the tables, i asked this question here: Bug after update TreeTable