on 10-16-2015 6:35 AM
example: i have in my page i have 3 tables like oTable1,
oTable2,
oTable3 and some other openui5 controls.
now
oTable1.addEventDelegate({
onAfterRendering: function(){
alert(" table1 rendered");
}
}, this);
instead of doing similer things to all controls .can i do for entire page
I don't think it is possible to move all your addEventDelegate functions from each control to one place.
The only way I can think of - is to use onAfterRendering function of the controller, but even then you'll have to call each desired control by its id, which doesn't seem like a good idea.
Cheers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can you check this link, After render table, it throws alert.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes, you can. Just add the delegate in your view instance. In the onInit of the controller, you can do as below.
this.getView().addEventDelegate({
onAfterRendering : function(){
console.log("view rendered");
}
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can't help much without you providing any info on how your code is.
Check out the working example - JS Bin - Collaborative JavaScript Debugging
Can you try to reproduce the issue ?
dragndropwithmvc.jsp
<!DOCTYPE html>
<meta charset="utf-8">
<script id='sap-ui-bootstrap' type='text/javascript'
src='https://openui5.hana.ondemand.com/resources/sap-ui-core.js'
data-sap-ui-theme='sap_bluecrystal'
data-sap-ui-libs="sap.ui.commons,sap.ui.table,sap.ui.layout,sap.ui.ux3,sap.m">
</script>
<script>
// Include jquery UI plugins
$.sap.require('sap.ui.thirdparty.jqueryui.jquery-ui-core');
$.sap.require('sap.ui.thirdparty.jqueryui.jquery-ui-widget');
$.sap.require('sap.ui.thirdparty.jqueryui.jquery-ui-mouse');
$.sap.require('sap.ui.thirdparty.jqueryui.jquery-ui-draggable');
$.sap.require('sap.ui.thirdparty.jqueryui.jquery-ui-sortable');
</script>
<script>
sap.ui.localResources("oui5mvc");
sap.ui.jsview("oui5mvc.dragndropwithmvc");
</script>
<body class="sapUiBody" role="application">
<div id="content"></div>
<div id="sample1"></div>
</body>
dragndropwithmvc.view.js
var oTable=null;
sap.ui.jsview("oui5mvc.dragndropwithmvc", {
getControllerName : function() {
return "oui5mvc.dragndropwithmvc";
},
createContent : function(oController) {
var oTextView = new sap.ui.commons.TextView();
oTextView.setText("A simple text to be displayed.");
oTextView.setTooltip("Some Tooltip");
// attach it to some element in the page
oTextView.placeAt("content");
//Create an instance of the table control
oTable = new sap.ui.table.TreeTable({
id : "oTable",
columns: [
new sap.ui.table.Column({label: "Name", template: "name"}),
new sap.ui.table.Column({label: "Description", template: "description"})
],
selectionMode: sap.ui.table.SelectionMode.Single,
// selectionBehavior: sap.ui.table.SelectionBehavior.Row,
enableColumnReordering: true,
expandFirstLevel: true,
toggleOpenState: function(oEvent) {
var iRowIndex = oEvent.getParameter("rowIndex");
var oRowContext = oEvent.getParameter("rowContext");
var bExpanded = oEvent.getParameter("expanded");
alert("rowIndex: " + iRowIndex +
" - rowContext: " + oRowContext.getPath() +
" - expanded? " + bExpanded);
}
});
}
});
dragndropwithmvc.controller.js
sap.ui.controller("oui5mvc.dragndropwithmvc", {
onInit: function() {
this.getView().addEventDelegate({
onAfterRendering : function(){
alert(this.getView());
}
});
/* oTable.addEventDelegate({
onAfterRendering: function(){
alert();
$("#oTable tbody tr").draggable({
helper: "clone"
});
}
}, this);*/
//Define some sample data
var oData = {
root:{
name: "root",
description: "root description",
checked: false,
0: {
name: "item1",
description: "item1 description",
checked: true,
0: {
name: "subitem1-1",
description: "subitem1-1 description",
checked: true,
0: {
name: "subsubitem1-1-1",
description: "subsubitem1-1-1 description",
checked: true
},
1: {
name: "subsubitem1-1-2",
description: "subsubitem1-1-2 description",
checked: true
}
},
1: {
name: "subitem1-2",
description: "subitem1-2 description",
checked: true,
0: {
name: "subsubitem1-2-1",
description: "subsubitem1-2-1 description",
checked: true
}
}
},
1:{
name: "item2",
description: "item2 description",
checked: true,
0: {
name: "subitem2-1",
description: "subitem2-1 description",
checked: true
}
},
2:{
name: "item3",
description: "item3 description",
checked: true
}
}
};
for (var i = 0; i < 20; i++) {
oData["root"][2][i] = {
name: "subitem3-" + i,
description: "subitem3-" + i + " description",
checked: false
};
}
this.drawTable(oData);
},
drawTable: function(oData) {
//alert(JSON.stringify(oData));
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(oData);
oTable.setModel(oModel);
oTable.bindRows("/root");
oTable.placeAt("sample1");
},
onAfterRendering: function() {
},
});
i want to use jquery draggable and droppable
in this code i put one table only but for my requirement i want to use 2 or more tables and other controls to.so that instead of add addEventDelegate to each control i would like apply jquery draggable and droppable after complete view is render
Srinivas,
May I know the reason, why are you using placeAt method inside view and controller. I see your code inside the view as -
// attach it to some element in the page
oTextView.placeAt("content");
And in controller also, I see it as -
drawTable: function(oData) {
//alert(JSON.stringify(oData));
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(oData);
oTable.setModel(oModel);
oTable.bindRows("/root");
oTable.placeAt("sample1");
}
Remove the above placeAt methods from both and do in index.html as
var oView = sap.ui.jsview("oui5mvc.dragndropwithmvc");
oView.placeAt("content");
After doing few changes in your code, addEventDelegate is able to hit. Check the sample here - Plunker
Regards,
Sai Vellanki.
I am not sure if I understand your problem right, but the views already have an event called onAfterRendering that does not need to be added manually.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.