Question

I have a sapui5 tree table, which has 2 columns(1: text views, 2: dropdownboxes). Data for table:

var oData = [
                                {
            Scopes : "QT15", ExecutionGroup: "group2", 
            0 : {Scopes : "Job1",  ExecutionGroup: "",  
                0 : {Scopes : "Act1",  ExecutionGroup: "",
                    0 : {Scopes : "Material1",ExecutionGroup: ""},
                    1 : {Scopes : "Material2",ExecutionGroup: ""},
                    2 : {Scopes : "Material3",ExecutionGroup: ""}
                },
                1 : {Scopes : "Act2",  ExecutionGroup: ""},
                2 : {Scopes : "Act3",  ExecutionGroup: ""}
            },
            1 : {Scopes : "Job2",  ExecutionGroup: "", 
                0 : {Scopes : "11111",  ExecutionGroup: ""},
                1 : {Scopes : "22222",  ExecutionGroup: ""},
                2 : {Scopes : "33333",  ExecutionGroup: ""}
                }
            },
            {
            Scopes : "QT16",  ExecutionGroup: "",// ExecutionGroup: "exgroup1", 
            0 : {Scopes : "Job1",  ExecutionGroup: "", 
                0 : {Scopes : "11111",  ExecutionGroup: ""},
                1 : {Scopes : "22222",  ExecutionGroup: ""},
                2 : {Scopes : "33333",  ExecutionGroup: ""}
                },
            1 : {Scopes : "Job2",  ExecutionGroup: "", 
                0 : {Scopes : "11111",  ExecutionGroup: ""},
                1 : {Scopes : "22222",  ExecutionGroup: ""},
                2 : {Scopes : "33333",  ExecutionGroup: ""}
                }
            }
        ];

Data for DropDown: var dataDD = [ {value:"group1"}, {value:"group2"}, {value:"group3"} ];

bunding data to the model:

var oModel = new sap.ui.model.json.JSONModel();
    oModel.setData({
    oData: oData,
    dataDD: dataDD
});

sap.ui.getCore().setModel(oModel);

Model is bunded to the table and DropDown is set as an template on column. The functionality supposed to come, that if the user chooses any value from DD, the defaulted DD value of all the children of that node have to change to that value. Initially value on DD is “group1”. If parent DD value is changed to “group2”, displayed DD value of children must be set to “group2”).
I want to trigger an function on DD change.

var oDropdownBox = new sap.ui.commons.DropdownBox({
    change: function(evt){

        var path = evt.getSource().getBindingContext().getPath();
        var value = evt.getSource().getValue();
        var currentContextObj = sap.ui.getCore().getModel().getProperty(path);

        console.log("path: " + path);
        refreshChilds();
    }
});

How can I check if the node on the tree has a child node? Many thanks!

Was it helpful?

Solution

not sure i fully understand question, but to see if context has a child 0 or 1

var obj = evt.getSource().getBindingContext().getObject();

var hasChild = (obj.hasOwnProperty(0) || obj.hasOwnProperty(1));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top