My Data
var myData= {
user:[{id:"1",firstname:"x",lastname:"k"},
{id:"2",firstname:"y",lastname:"k"},
{id:"3",firstname:"z",lastname:"k"}],
expense:[{expenseno:"1",uid:"1",item:"c",amount:"1500"},
{expenseno:"2",uid:"2",item:"t",amount:"1150"},
{expenseno:"3",uid:"3",item:"p",amount:"500"},
{expenseno:"4",uid:"1",item:"y",amount:"1000"},
{expenseno:"5",uid:"2",item:"t",amount:"3500"},
{expenseno:"6",uid:"3",item:"s",amount:"3500"},
{expenseno:"7",uid:"1",item:"q",amount:"900"}],
};
I want to create a SplitApp(Master-Details page). I have created the Master page as a List of User Name from the User dataset. The list should contain the firstname.
var oList = new sap.m.List({
id:"listId",
mode: sap.m.ListMode.SingleSelect,
select: function(){
oController.itemSelected();
}
});
var oItemTemplate = new sap.m.StandardListItem({
id: "sList",title:"{firstname}"});
oList.bindAggregation("items","/user",oItemTemplate );
return new sap.m.Page({
id:"master",
title: "Claims",
content: [oList]
});
Now in details page I want to show the expenses made by that user(when i select a specific user from master view) in a table.
Now my question is how to filter data and use it for the Details view. Example: If I select User "X" from Master view list, I should get id 1 from the "user" and Expenseno 1,4 and 7 (as they are associated with uid 1) from "expense", finally i will show the expenses of uid 1 in the details view.
Code I am trying
itemSelected: function(){
var app = sap.ui.getCore().byId("appId");
var list = sap.ui.getCore().byId("listId");//will get instance of the list
var sItem = list.getSelectedItem();//should know which item we selected
//*** How To filter ***//
//var Model = new sap.ui.model.json.JSONModel(oitem); // will use it for details
//sap.ui.getCore().setModel(Model,'item');// view(oitem should contain the filtered data)
app.toDetail("detailsid","show");
},