<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<meta name="description" content="UI5 XML view example" />
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8' />
<title>UI5 - JSON DataBinding</title>
<script id='sap-ui-bootstrap' type='text/javascript'
src='https://openui5.hana.ondemand.com/resources/sap-ui-core.js'
data-sap-ui-theme='sap_bluecrystal'
data-sap-ui-libs='sap.ui.commons, sap.ui.table'></script>
<script id="view1" type="ui5/xmlview">
<core:view xmlns:core="sap.ui.core"
xmlns="sap.ui.commons"
xmlns:table="sap.ui.table"
xmlns:html="http://www.w3.org/1999/xhtml"
controllername="view.Main">
<table:Table width="100%" id="players" visibleRowCount="5" selectionMode="Single" editable="false" rows="{/data}">
<table:title><Label text="XML View"></Label></table:title>
<table:Column>
<Label text="Player Name" />
<table:template><TextField value="{name}"></TextField></table:template>
</table:Column>
<table:Column>
<Label text="Email Address" />
<table:template><TextField value="{age}"></TextField></table:template>
</table:Column>
</table:Table>
</core:view>
</script>
<script>
var player = [
{ name: "Rajesh", age: "21" },
{ name: "Kunal Jauhari", age: "21" },
{ name: "Ashish Singh", age: "21" },
{ name: "Ansuman Parhi", age: "21" },
{ name: "Arup Kumar", age: "21" },
{ name: "Deepak Malviya", age: "21" },
{ name: "Seshu", age: "21" },
{ name: "Ankush Datey", age: "21" },
{ name: "Tapesh Syawaria", age: "21" },
{ name: "Mahesh", age: "21" },
{ name: "Vinay Joshi", age: "21" },
{ name: "Ardhendu Karna", age: "21" },
{ name: "Abhishek Shukla", age: "21" },
{ name: "Kashim", age: "21" },
{ name: "Vinayak", age: "21" }
];
// create a "json" Model
var oModel = new sap.ui.model.json.JSONModel();
/***** LOADING THE DATA *****/
sap.ui.controller("view.Main", {
onInit: function (oEvent) {
alert("onInit()");
},
onAfterRendering: function (oEvent) {
alert("onAfterRendering");
}
});
var oView = sap.ui.xmlview({
viewContent: jQuery("#view1").html()
});
var oModel = new sap.ui.model.json.JSONModel( {
data: player
});
oView.setModel(oModel);
oView.placeAt("content");
// Filter table
var Find = function () {
var oFilter1 = new sap.ui.model.Filter("name", sap.ui.model.FilterOperator.Contains, document.getElementById("searchFor").value);
var oFilter2 = new sap.ui.model.Filter("age", sap.ui.model.FilterOperator.Contains, document.getElementById("searchFor").value);
var allFilter = new sap.ui.model.Filter([oFilter1, oFilter2], false);
oView.byId("players").getBinding("rows").filter(allFilter);
}
// Observe if scrolling up or down
var lastScroll = 0;
setTimeout(function(){
$("#__xmlview0--players-vsb-sb").scroll(function () {
var st = $(this).scrollTop();
var scrollpos = document.getElementById("__xmlview0--players-vsb-sb");
if (st > lastScroll) {
console.log("scrolling down");
} else {
console.log("scrolling up");
}
if(st > document.getElementById("__xmlview0--players-vsb-sb").clientHeight - 20) {
console.log("works");
}
lastScroll = st;
console.log(lastScroll);
console.log(scrollpos.clientHeight);
});
}, 900);
</script>
</head>
<body class='sapUiBody'>
<div id='content'></div>
<input id='searchFor' type="search" />
<button id="btnFind" onclick="Find()">Find</button>
</body>
</html>
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |