Skip to content
This repository has been archived by the owner on Aug 22, 2018. It is now read-only.

DevExpress/DevExtreme-Data-JayData

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

DevExtreme JayData data layer extension

The JayData extension enables your DevExtreme application to work with an OData service accessed via the JayData library. The extension includes the JayDataStore class that wraps the JayData functionality with the Store interface accepted within the DevExtreme data layer. To create a JayDataStore instance, call its constructor and pass the required configuration object to it. The configuration object may contain the following fields:

  • queryable - Required. Takes on the JayData entity that should be accessed via this JayDataStore instance.
  • autoCommit - Optional. Specifies whether the changes made to the data are immediately committed to the server. The default value is false.
$data.Entity.extend("MyEntity", {
    id: { type: "int", key: true, computed: true },
    name: { type: String }
});
$data.EntityContext.extend("Database", { MyEntities: { type: $data.EntitySet, elementType: "MyEntity" }});

var dataBase = new Database({
    name: "oData",
    oDataServiceHost: ROOT_URL + "FakeOData"
});
//queryable only
dataBase.onReady().then(function() {
	var jdStore = new DevExpress.data.JayDataStore(dataBase.MyEntities);
});
//queryable with custom filter
dataBase.onReady().then(function() {
	var jdStore = new DevExpress.data.JayDataStore(dataBase.MyEntities.filter("it.name.startsWith('A')"));
});
//queryable and autoCommit
dataBase.onReady().then(function() {
	var jdStore = new DevExpress.data.JayDataStore({
		queryable: dataBase.MyEntities,
		autoCommit: true
	});
});

You can read and modify data associated with the current JayDataStore instance in the same way as data associated with any other Store. Besides the standard Store methods, the JayDataStore contains several JayData specific methods.

  • queryable() - returns the JayData entity object associated with this JayDataStore.
  • entityType() - returns the type of the entity associated with this JayDataStore instance.
  • entityContext() - returns the JayData context containing the entity associated with this JayDataStore instance.
var jdStore = new DevExpress.data.JayDataStore(dataBase.MyEntities);
jdStore.insert({
	id: 1,
	name: "EntityName"
}).done(function(values, id) {
	console.log(jdStore.entityType());
	console.log(jdStore.queryable().stateManager.trackedEntities);
	jdStore.entityContext().saveChanges();
});

NOTE: JayData extension requires the application to reference oDataProvider.js or oDataProvider.min.js.