on 01-24-2018 8:32 PM
I need to pass data from detail view to master view after selecting a checkbox as shown below.
on the detail controller I already have the checkbox function:
estSelect: function(oEvent) {
var isSelected = oEvent.getParameter("selected");
var cxt = oEvent.getSource().getBindingContext();
var wordName = cxt.getObject("Word");
if (isSelected) {
cxt.getModel().setProperty("percent", "100%", cxt);
this.updateSummary(wordName);
} else {
cxt.getModel().setProperty("percent", null, cxt);
}
},
I was trying to create a tree table with the data to the master view content:
updateSummary: function(mName) {
var summaryLocation = sap.ui.getCore().byId("<masterContentLocation>");
var oModel = new sap.ui.model.json.JSONModel([{
title: mName,
children: [{
title: mName
}]
}]);
sap.ui.require([], function() {
var oTree = new sap.m.Tree({});
oTree.setModel(oModel);
var oStandardTreeItem = new sap.m.StandardTreeItem({
title: "{title}"
});
oTree.bindItems("/", oStandardTreeItem);
oTree.placeAt(summaryLocation);
});
You can use EventBus for passing data between different controllers. For example:
Master controller (onInit):
var oEventBus = sap.ui.getCore().getEventBus();
function handleWordSelected(oData) {
var oModel = //get your master model here
var aItems = oModel.getProperty('/');
aItems.push({title: oData.word, children:[]});
oModel.updateBindings();
}
oEventBus.subscribe('wordSelected', handleWordSelected);
Detail controller (your checkbox select handler):
estSelect: function(oEvent) {
var isSelected = oEvent.getParameter("selected");
var cxt = oEvent.getSource().getBindingContext();
var wordName = cxt.getObject("Word");
if (isSelected) {
cxt.getModel().setProperty("percent", "100%", cxt);
this.updateSummary(wordName);
} else {
cxt.getModel().setProperty("percent", null, cxt);
}
var oEventBus = sap.ui.getCore().getEventBus();
oEventBus.publish('wordSelected', {word: wordName});
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here you have two options:
Send a message (from detail to master):
sap.ui.getCore().getEventBus().publish(channel, event, data);
Subscribe (master)
sap.ui.getCore().getEventBus().subscribe(channel, event, handler, listener);
Unsubscribe (master)
sap.ui.getCore().getEventBus().unsubscribe(channel, event, handler, listener);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
put them in model, which is shared to all view. no need to pass between each other....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.