$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: false, vro: false, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); Skip to Content
0

Simple Filter in UI5 list

May 09, 2017 at 01:03 AM

76

avatar image

Hi,

i have this json data:

and im displaying a list based on some filter as shown in belo my code:

createContent : function(oController) {
		var oModel = new sap.ui.model.json.JSONModel("json/names.json");
		sap.ui.getCore().setModel(oModel);
		var oList = new sap.m.List({
			headertText:"SAP Employee",
			itemPress:[oController.getitem,oController]
		});
		var oFilter1 = new sap.ui.model.Filter("module", sap.ui.model.FilterOperator.StartsWith, "A");
		oList.setModel(oModel);
		oList.bindItems({
		path:"/sap",
		template: new sap.m.StandardListItem({title:"{name}", description:"{module}",
				type:sap.m.ListType.Navigation,
				filters:[oFilter1]})
			
		});
		
 		var oPage = new sap.m.Page({
			title: "FirstPage",
			content: [
				oList
			]
		});
 		return oPage;
	}


});

however list displays all the data without considering filter. I have written this code based on below link:

https://help.sap.com/saphelp_uiaddon10/helpdata/en/91/f057786f4d1014b6dd926db0e91070/content.htm?frameset=/en/91/f0652b6f4d1014b6dd926db0e91070/frameset.htm¤t_toc=/en/e4/843b8c3d05411c83f58033bac7f072/plain.htm&node_id=299

https://archive.sap.com/discussions/thread/3817400

could anybody please help what im missing to filter my list data.

Thanks

json.png (27.6 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
avatar image
Former Member May 09, 2017 at 11:30 AM
1

Hi,

Apply filter to the binding, not to the template.. See below, it may works..

oList.bindItems({
		path:"/sap",
		template: new sap.m.StandardListItem({
				title:"{name}", 
				description:"{module}",
				type: sap.m.ListType.Navigation	
		}),
		filters: [oFilter1]			
});
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thank you Naresh !

0