我在XML视图中有三个不同状态的磁贴。当我点击特定的磁贴时,它应该导航到另一个XML,根据此状态显示表数据。我能够导航到平铺点击上的其他视图。但是,我的表显示所有数据,而不是显示该特定状态的数据。我想仅在点击相应的图块时显示打开的状态数据:
我使用oModel.read()
仅向图块显示状态计数。
使用代码
oModel.read("/ServiceRequestCollection?$filter= CustomerID eq '1001192'", {
success: function(oData, response) {
var fld = [];
fld = oData.results;
var x = [];
var count1 = 0;
var count2 = 0;
var count3 = 0;
for (var i = 0; i < oData.results.length; i++) {
var p1 = "1001190";
var obj = fld[i];
if(x[obj.ProductID] === p1) {
x[obj.ServiceRequestLifeCycleStatusCodeText] = [obj.ServiceRequestLifeCycleStatusCodeText];
x[obj.ServiceRequestLifeCycleStatusCodeText].push(obj);
// console.log(x);
}
if (fld[i].ServiceRequestLifeCycleStatusCodeText === "Open") {
var OpenArray = [];
count1 = count1 + 1;
OpenArray.push(count1);
OpenArray = {tilearray:OpenArray};
var oVizFrame3Model = new sap.ui.model.json.JSONModel(OpenArray);
var oTile = oView.byId("opentile");
oTile.setModel(oVizFrame3Model);
oTile.setNumber(count1);
// return OpenArray;
} else {
if (fld[i].ServiceRequestLifeCycleStatusCodeText === "In Process") {
var InProcessArray = [];
count2 = count2 + 1;
InProcessArray.push(count2);
InProcessArray = {tilearray:InProcessArray};
oVizFrame3Model = new sap.ui.model.json.JSONModel(InProcessArray);
oTile = oView.byId("inprocesstile");
oTile.setModel(oVizFrame3Model);
oTile.setNumber(count2);
// return TileData;
}
}
if (fld[i].ServiceRequestLifeCycleStatusCodeText === "Completed") {
var CompletedArray = [];
count3 = count3 + 1;
CompletedArray.push(count3);
CompletedArray = {tilearray:CompletedArray};
oVizFrame3Model = new sap.ui.model.json.JSONModel(CompletedArray);
oTile = oView.byId("completedtile");
oTile.setModel(oVizFrame3Model);
oTile.setNumber(count3);
// return TileData;
}
}
}
});
表数据从不同的数组加载到该视图。请提供有关如何完成此任务的建议。
答案 0 :(得分:0)
您需要使用过滤器来过滤数据。我正在向您展示执行状态为Open的代码。这里'iHome1'是你桌子的id。
var filters = [];
var f1 = new sap.ui.model.odata.Filter('CustomerID', [{operator:"EQ",value1:"1001192"}]);
var f2 = new sap.ui.model.odata.Filter('Status', [{operator:"EQ",value1:"SALESREP"}]);
filters.push(f1);
filters.push(f2);
var oModel = new sap.ui.model.odata.ODataModel("/ServiceRequestCollection",
false);
var oHtable1 = sap.ui.getCore().byId("iHome1")
oHtable1.setModel(oModel);
oHtable1.bindRows({path:"/ServiceRequestCollection", filters: filters} );