on 2017 Jul 26 12:44 AM
Hello guys, Following SAP's standard with Component.js am developing an application I have built before with this concept. Am having an issue accessing a UI element from another View in a different controller. I have an Employee_list.XML view and an Employee.XML. After performing CRUD functions on Employee.XML Controller , I want to get the Table in Employee_list View and refresh before navigating. I have pasted the Component.js , and respective functions in respective controllers. Please can some help, It's annoying I have built this application successfully without Component.js and now am stalk.
Component.js
sap.ui.core.UIComponent.extend("sap.demo.Component",{
metadata: {
routing: {
config: {
viewType: "XML",
viewPath: "sap.demo.Views",
targetAggregation:"pages",
targetControl: "App",
clearTarget: false,
transition: "slide"
},
routes: [
{
pattern: "",
name: "Employee_List",
view: "Employee_List",
viewType: "XML",
targetAggregation: "pages",
targetControl: "App",
},
{
pattern: "Employee/{cat}",
name: "Employee",
view: "Employee",
viewType: "XML",
targetAggregation: "pages",
targetControl: "App",
}
]
}
},
init:function() {
jQuery.sap.require("sap.m.routing.RouteMatchedHandler");
jQuery.sap.require("sap.ui.core.routing.HashChanger");
sap.ui.core.UIComponent.prototype.init.apply(this, arguments);
this._router = this.getRouter();
//initlialize the router
this._routeHandler = new sap.m.routing.RouteMatchedHandler(this._router);
this._router.initialize();
},
createContent:function() {
var oView = sap.ui.view({
id: "app",
viewName: "sap.demo.Views.Main",
type: "XML",
viewData: {component: this}
});
var oModel = new sap.ui.model.odata.
ODataModel("proxy/http/firs-erp-dev.internal.firs.gov.ng:8000/sap/opu/odata/sap/ZTABLE1_SRV/");
sap.ui.getCore().setModel(oModel,"Employees");
oView.setModel(oModel,'Employees');
return oView;
}
********************************************************
Employee_list.controller
press2:function(oEvent) {
var Context = oEvent.getParameter("listItem");
var path = Context.oBindingContexts.Employees.sPath; /
var start = path.lastIndexOf('(') + 2;
var Index = path.substring(start,path.length);
var cat = Index.substring(0,3);
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.navTo('Employee',{cat:cat});
},
******************************************************
Employee.controller
onEmployeeBack:function() {
var oEmployeeTable = sap.ui.getCore().byId("idEmployeeTable"); //This is where my problem is...I cant access Employee table id = idEmployeeTable in the Employee_list view
}
Request clarification before answering.
Hello Jun Wu , I have tried using this.byId and it didn't work .. I thought this.byId can only work for components in the same controller...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
73 | |
30 | |
8 | |
8 | |
7 | |
6 | |
6 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.