点击此处---> 群内免费提供SAP练习系统(在群公告中)
加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)
我的问题是关于:我正在做动态表并获取结果,但我想以不同的方式显示,例如转置。 因为我有N个列值和5个行值。 所以我想以垂直方式显示表格,例如转置(列值应显示为行,行值应显示为列)
var columnData = [{columnName:" Attr1"},{columnName:" Attr2"},{columnName:" Attr3"},{columnName:" Attr4"},{columnName:" Attr5"},{columnName: " Attr6"},{columnName:" Attr7"},{columnName:" Attr8"},{columnName:" Attr9"},{columnName:" Attr10"},{columnName:" Attr11"}]];
var rowData = [{Attr1:" Mat1",Attr2:" Product1",Attr3:" Reason1",Attr4:" Global1",Attr5:"印度",Attr6:"品牌1",Attr7:" Size-L ",Attr8:" Falv1",Attr9:" Mat1",Attr10:" Cat1",Attr11:" UOM1"},{Attr1:" Mat2",Attr2:" Product2",Attr3:" Reason2",Attr4:" Global2 ",Attr5:"英国",Attr6:"品牌2",Attr7:" Size-M",Attr8:" Falv2",Attr9:" Mat2",Attr10:" Cat2",Attr11:" UOM2"},{Attr1: " Mat3",Attr2:" Product3",Attr3:" Reason3",Attr4:" Global3",Attr5:" US",Attr6:" Brand3",Attr7:" Size-XL",Attr8:" Falv3",Attr9: " Mat3",Attr10:" Cat3",Attr11:" UOM3"}];
这是我得到的实际结果:
我想要的预期结果:
感谢与问候
Preeti
(18.9 kB)
大家好,
我得到了转置表解决方案。 这是代码:
//*********查看代码*************//
<表项目=" {路径:'DT>/rowData2',工厂:'.productListFactory'}" column =" {DT>/colData2}" mode =" SingleSelectMaster" select =" handleGLItemPress">
<列>
//***************控制器代码*****************//
onInit:function(){
var data = {};
var colData = [
{colName:" Attr1"},
{colName:" Attr2"},
{colName:" Attr3"}]
var rowData = [
{Attr1:" Mat1",Attr2:" Mat2",Attr3:" MAt3"},
{Attr1:" Mat11",Attr2:" Mat22",Attr3:" MAt33"}]
data.colData2 = [];
data.colData2.push({colName:""})
data.rowData2 = [];
对于(var i = 0; i
{
data.colData2.push({colName:""})
}
for(colData中的var i){
var cName,obj = {};
for(var j = 0; j
{
cName = colData [i] [" colName"];
obj [cName + j] = rowData [j] [cName];
}
obj [" colName"] = cName;
data.rowData2.push(obj);
}
var oModel = new sap.ui.model.json.JSONModel(data);
this.getView()。setModel(oModel," DT");
},
productListFactory:function(sId,oContext){
var oUIControl = [];
var sObj = oContext.getObject();
oUIControl.push(new sap.m.Label({text:sObj.colName}));
for(sObj中的var i){
if(i ==" colName")
{
继续;
}
oUIControl.push(new sap.m.Label({text:sObj [i]})));
}
返回新的sap.m.ColumnListItem({cells:oUIControl});
},
一周热门 更多>