Created
February 23, 2018 10:49
-
-
Save helloanoop/930aa2b73c104ce38f79dbdba60bd971 to your computer and use it in GitHub Desktop.
OJET Table with Serverside data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="stylesheet" href="../node_modules/@oracle/oraclejet/dist/css/alta/oj-alta-min.css"/> | |
<script type="text/javascript" src="../node_modules/requirejs/require.js"></script> | |
<script type="text/javascript" src="main.js"></script> | |
<oj-table data="[[datasource]]" | |
columns='[[columns]]' | |
row-renderer='[[oj.KnockoutTemplateUtils.getRenderer("row_tmpl", true)]]'> | |
</oj-table> | |
<script type="text/html" id="row_tmpl"> | |
<tr> | |
<td data-bind="text:id"></td> | |
<td data-bind="text:name"></td> | |
<td data-bind="text:age"></td> | |
</tr> | |
</script> | |
<script> | |
require(['ojs/ojcore', 'knockout', | |
'jerry/user', 'jerry/users', | |
'ojs/ojmodel', 'ojs/ojtable', | |
'ojs/ojcollectiontabledatasource', | |
'ojs/ojknockout', 'ojs/ojbutton'], function(oj, ko, User, Users) { | |
function ViewModel() { | |
var self = this; | |
this.columns = [ | |
{"headerText": "Id", "field": "id", "sortable": "disabled"}, | |
{"headerText": "Name", "field": "name", "sortable": "disabled"}, | |
{"headerText": "Age", "field": "age", "sortable": "disabled"} | |
]; | |
this.users = new Users(); | |
this.datasource = ko.observable(); | |
this.datasource(new oj.CollectionTableDataSource(this.users)); | |
this.users | |
.fetch() | |
.then(function(data){ | |
console.log(data); | |
}) | |
.catch(function(error){ | |
console.log(error); | |
}) | |
} | |
ko.applyBindings(new ViewModel()); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment