OData.org post - Robesz
by JayData
HTML
<script src="http://include.jaydata.org/datajs-1.0.3.min.js"></script>
<script src="http://include.jaydata.org/1.3.0beta/jaydata.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.rc.1/handlebars.js"></script>
<script src="http://include.jaydata.org/1.3.0beta/jaydatamodules/handlebars.js"></script>
<script id="Product" type="text/x-handlebars">
<li>{{Product_Name}}</li>
</script>
<div id="ProductList" style="width:300px;float:left"></div>
JavaScript
$data.initService('http://jaydata.org/examples/Northwind.svc').then(function (northwind, factory) {
//northwind.Products.renderItemsTo('#ProductList');
//northwind.Products.length(function(count) {alert(count);});
northwind.prepareRequest = function (request) {
request[0].timeoutMS = 5;
console.log(16);
}
northwind.Products.orderBy('it.Category_ID').orderByDescending('it.Product_Name').toArray(function(a){console.dir(a)}).fail(function() {alert('fail')});
//northwind.Products.withInlineCount().renderItemsTo('#ProductList');
//northwind.Products.filter("it.Product_Name.startsWith('Ch')")
//.renderItemsTo('#ProductList');
/*
northwind.Products.filter(function (p) {
return (p.Product_Name.startsWith('Ch') && p.Unit_Price < 19) ||
(p.Discontinued && p.Units_In_Stock > 0);
})
.renderItemsTo('#ProductList');
*/
/*
northwind.Products.take(10).skip(20)
.renderItemsTo('#ProductList');*/
/*
northwind.Products
.map(function(p) {
return {Product_Name: p.Product_Name, Unit_Price: p.Unit_Price};})
.toArray(function(a) {alert(JSON.stringify(a));});
*/
});