如何通过从表中选择一行来将数据显示到下一页?

2020-09-04 01:59发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中) 大家好, 我有两个观点...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


大家好,

我有两个观点

1.View1.view.xml

2。 detail.view.xml

现在,当我从表格中选择任何行时,我想在下一页中显示其详细信息

我已经编写了代码,但无法选择任何行。

有人可以帮我吗?

 return Controller.extend(" com.TestTable.controller.View1",{
 onInit:函数(){


 var oTable = this.getView()。byId(" tableId");
 var oModel = new sap.ui.model.json.JSONModel();


 oModel.loadData(" model/employees.json");
 oTable.setModel(oModel);


 },


 onNavigation:函数(oEvent){


 var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
 var oItem = oEvent.getSource();
 oRouter.navTo(" detail",{
 userId:oItem.getBindingContext()。getProperty(" userId")
 });
 },



 onItemPress:函数(oEvent){
 var oItem = oEvent.getParameter(" listItem")||  oEvent.getSource();
 var oCtx = oItem.getBindingContext();
 var sPath = oCtx?  oCtx.getPath():未定义;


 alert("列表项被按下:绑定路径:" + sPath);
 },
 

(81.3 kB)
4条回答
Violet凡
2020-09-04 02:12
 sap.ui.define([
 " sap/ui/core/mvc/Controller",
 " sap/ui/model/Filter",
 " sap/ui/core/Fragment",
 " sap/ui/model/json/JSONModel"
 ],函数(控制器,过滤器,片段,JSONModel){
 "使用严格";


 return Controller.extend(" com.TestTable.controller.View1",{
 onInit:函数(){


 var oTable = this.getView()。byId(" tableId");
 var oModel = new sap.ui.model.json.JSONModel();


 oModel.loadData(" model/employees.json");
 oTable.setModel(oModel);


 },


//按钮代码
/* goToDetail:function(){
 var oRouter = new sap.ui.core.UIComponent.getRouterFor(this);
 oRouter.navTo(" detail");
 },*/


 onNavigation:函数(oEvent){


/* var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
 var oItem = oEvent.getSource();
 oRouter.navTo(" detail",{
 userId:oItem.getBindingContext()。getProperty(" userId")
 }); */


 var oPath = oEvent.getSource()。getBindingContextPath();
 var selectedItem = oEvent.getSource()。getBindingContext(" oModel")。getProperty(oPath);
 var oRouter = sap.ui.core.UIComponent.getRouterFor(this);


 oRouter.navTo(" detail",{


 userId:selectedItem.userId,
 jobTitle:selectedItem.jobTitle,
 firstName:selectedItem.firstName,
 lastName:selectedItem.lastName,
 employeeCode:selectedItem.employeeCode,
 地区:selectedItem.region,
 contactNo:selectedItem.contactNo,
 国家/地区:selectedItem.country
 });


 },


/* onSelectionChange:函数(oEvent){
 var oSelectedItem = oEvent.getParameter(" listItem");
 var oModel = oSelectedItem.getBindingContext()。getObject();
 alert(JSON.stringify(oModel));


/* var asnnum = rowItems [0] .mAggregation.cell [1] .getProperty(" text"); */
/**/


 onItemPress:函数(oEvent){
/* var path = oEvent.getParameter('listItem')。getBindingContext()。getPath();


 var selectedRow = this.byId('tableId')。getModel()。getProperty(path);
 console.log(selectedRow.userId);  */

 var oPath = oEvent.getSource()。getBindingContextPath();
 var selectedItem = oEvent.getSource()。getBindingContext(" oModel")。getProperty(oPath);
 var oRouter = sap.ui.core.UIComponent.getRouterFor(this);


 oRouter.navTo(" detail",{


 userId:selectedItem.userId,
 jobTitle:selectedItem.jobTitle,
 firstName:selectedItem.firstName,
 lastName:selectedItem.lastName,
 employeeCode:selectedItem.employeeCode,
 地区:selectedItem.region,
 contactNo:selectedItem.contactNo,
 国家/地区:selectedItem.country


 });
 

一周热门 更多>