This file contains 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
var oProviderConfig = { | |
name: 'oData', | |
oDataServiceHost: 'http://localhost:3000/odata' | |
}; | |
var NorthwindContext = $data('JayStack.NorthwindContext'); | |
var northwind = new NorthwindContext(oProviderConfig); | |
northwind.onReady(function () { | |
northwind.Categories.toArray(app.renderCategories); |
This file contains 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
<table id="categoryTable" class="table span3 reset-m" style="margin: 0 10px 10px 0 !important;"> | |
<thead> | |
<tr> | |
<th>Category name</th> | |
<th>Description</th> | |
</tr> | |
</thead> | |
<tbody> | |
</tbody> | |
</table> |
This file contains 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
<head> | |
<title></title> | |
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> | |
<script src="lib/jaydata/jaydata.js"></script> | |
<script src="lib/jaydata/jaydatamodules/deferred.js"></script> | |
<script src="scripts/Northwind.js"></script> | |
<script src="scripts/app.js"></script> | |
</head> |
This file contains 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
$data.initService(oProviderConfig.oDataServiceHost) | |
.then(function (northwind, contextFactory, contexType) { | |
//you can use your northwind context instace | |
}); |
This file contains 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
var oProviderConfig = { | |
name: 'oData', | |
oDataServiceHost: 'http://localhost:3000/odata' | |
}; | |
var NorthwindContext = $data('JayStack.NorthwindContext'); | |
var northwind = new NorthwindContext(oProviderConfig); | |
northwind.onReady(function () { | |
// work with your data |
This file contains 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
//start your own service endpoint from https://github.com/jaystack/odata-v4-northwind-example-service | |
C:\NorthWindEditor>JaySvcUtil -m http://localhost:3000/odata/$metadata -o northwind.js |
This file contains 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
$data.EntityContext.extend('NorthwindContext', { | |
'Products': { type: $data.EntitySet, elementType: NorthwindModel.Product }, | |
'Categories': { type: $data.EntitySet, elementType: NorthwindModel.Category } | |
}); |
This file contains 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
$data("$data.Entity").extend("Northwind.Product", { | |
_id: { "type": "Edm.String", "nullable": false, "required": true, "key": true }, | |
Name: { "type": "Edm.String", "nullable": false, "required": true }, | |
CategoryId: { "type": "Edm.String", "nullable": false,"required": true }, | |
QuantityPerUnit: { "type": "Edm.String", "nullable": false, "required": true }, | |
UnitPrice: { "type": "Edm.Decimal", "nullable": false, "required": true }, | |
Discontinued: { "type": "Edm.Boolean", "nullable": false, "required": true } | |
}); |
This file contains 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
var queryString = ("/Northwind.svc/Products?" | |
+ "$filter=((Category/Category_ID eq 1)or" | |
+ "substringof('tofu',tolower" | |
+"(Product_Name)))&" | |
+ "$orderby=Category/Category_Name&" | |
+ "$select=Product_Name"); | |
$.ajax({ | |
url: queryString, | |
dataType: 'JSON', |
This file contains 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
$data.initService('http://yourhost/yourODataService') | |
.then(function (context) { | |
// manage your data through context with JSLQ | |
}); |
NewerOlder