Skip to Content
0

Filter in sap.ui.table not working

May 10, 2017 at 06:21 PM

61

avatar image

Hi,

***************JSON***********************************
{
"item":[
	{"vbeln":"00004971", "posnr":"0010", "matnr":"eek23 6201"},
	{"vbeln":"00004971", "posnr":"0020", "matnr":"eek23 6200"},
	{"vbeln":"00004971", "posnr":"0030", "matnr":"eek23 5201"},
	{"vbeln":"00004972", "posnr":"0010", "matnr":"eek23 4201"}
],
"header":[
	{"vbeln":"00004971", "auart":"zabc"},
	{"vbeln":"00004972", "auart":"zdef"}
]
}
*******************FirstView*****************************
var oModel= sap.ui.model.json.JSONModel("json/order.json");
		sap.ui.getCore().setModel(oModel);
		var oList = new sap.m.List({
			headerText:"SaleOrder",
			//mode : sap.m.ListMode.SingleSelect
			//items:[oList1]
		});
	
//oList.setModel(oModel);
oList.bindItems({
path:"/header",
template:new sap.m.StandardListItem({title:"{vbeln}", description:"{auart}",
		type:sap.m.ListType.Navigation,
		press:[oController.hit,oController]})
		});
 	var oPage = new sap.m.Page({
		title: "FilterApp",
		content: [ oList ]
		});
 		return oPage;
	}
**************FirstController with hit method
hit: function(oEvt){
	var k = oEvt.getSource();
	var p = k.getBindingContext();
	var sVal = p.getProperty("vbeln");
	var oModel1 = new sap.ui.model.json.JSONModel({"data1":sVal});
		sap.ui.getCore().setModel(oModel1,"TMOD");
		app.to("idSecond1");
		//debugger;
	}

************************SecondView
var oCol1 = new sap.ui.table.Column({label: new sap.m.Text({text:"Order"}),
			template:new sap.m.Text({text:"{vbeln}"})
		});
		
var oCol2 = new sap.ui.table.Column({label: new sap.m.Text({text:"Item"}),
			template:new sap.m.Text({text:"{posnr}"})
		});
		
var oCol3 =new sap.ui.table.Column({label:new sap.m.Text({text:"material"}),
			template:new sap.m.Text({text:"{matnr}"})
		});
		
		var oTab = new sap.ui.table.Table();
		oTab.addColumn(oCol1);
		oTab.addColumn(oCol2);
		oTab.addColumn(oCol3);
		var aFilter = new sap.ui.model.Filter("{vbeln}", sap.ui.model.FilterOperator.EQ, "{TMOD>/data1}");
		oTab.bindRows({path:"/item", filters:[aFilter]});
		var oPage = new sap.m.Page({
			title: "Second Page",
			content: [
			oTab
			]
		});
 		return oPage;

above is the code snippet wherein i have a list showing Order number and its type in first view. In controller im fetching the line being clicked by user. im setting a model with that particular order number. In second view im showing item detail for order and filtering the list w.r.t., order been clicked in first view. for some reason fiter functionality is not working.

could anybody please advise me on this.

Thanks

scn.txt (2.3 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Sharath M G May 10, 2017 at 06:42 PM
0

Firstly check in the line at aFilter, if it is being built as expected, prior to binding the data to the tab control.

If you observe that the actual value to be filtered (vblen) and the data (val1) is built as expected, then try to move the braces as shown in the line below and test.

oTab.bindRows(path:"/item", {filters:[aFilter]});

Regards,

Sharath

Show 2 Share
10 |10000 characters needed characters left characters exceeded

you mean in debugging?

0

Yes, Debugging.

0