Skip to content

Instantly share code, notes, and snippets.

@gbvaibhav
Created October 14, 2016 09:43
Show Gist options
  • Save gbvaibhav/38f57e1869bd4b627183f0554c3d3c90 to your computer and use it in GitHub Desktop.
Save gbvaibhav/38f57e1869bd4b627183f0554c3d3c90 to your computer and use it in GitHub Desktop.
Sapui5 example for sap.m.Input suggestion items http://jsbin.com/bikaci
<!DOCTYPE html>
<html><head>
<meta name="description" content="SAPUI5 example" />
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<title>SAPUI5 Example GB</title>
<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.m,sap.ui.layout,sap.ui.core"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-theme="sap_bluecrystal"></script>
<script>
var data = {
results:[
{
name:"Rach",
place:"Bangalore"
},
{
name:"Vijay",
place:"mumbai"
},
{
name:"gaurav",
place:"Hyd"
},
{
name:"Vishal",
place:"mangalore"
}
]
};
var array
var input = new sap.m.Input({
showSuggestion:true,
});
input.bindAggregation("suggestionItems",{
path:"/results",
template: new sap.ui.core.Item({
text:"{name}"
})
});
var model = new sap.ui.model.json.JSONModel(data);
input.setModel(model);
input.setFilterFunction(function(sTerm, oItem) {
// A case-insensitive 'string contains' style filter
return oItem.getText().match(new RegExp(sTerm, "i"));
});
var page = new sap.m.Page({
title:"SAPUI5 Example GB",
content:[
input
]
});
// finally place the App into the UI
var app = new sap.m.App({
pages: [page]
}).placeAt("content");
</script>
</head>
<body>
<div id='content'></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment