Skip to content

Commit 5e10357

Browse files
Data Layer section overhaul (DevExpress#6978) (DevExpress#7004)
1 parent 2be4f5a commit 5e10357

30 files changed

+216
-196
lines changed

concepts/70 Data Binding/5 Data Layer/0 Overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
DevExtreme includes a data layer, which is a set of complementary components that enable you to read and write data. The core data layer objects are [DataSource](/api-reference/30%20Data%20Layer/DataSource '/Documentation/ApiReference/Data_Layer/DataSource/') and [Stores](/concepts/70%20Data%20Binding/5%20Data%20Layer/1%20Creating%20DataSource/3%20What%20Are%20Stores.md '/Documentation/Guide/Data_Binding/Data_Layer/#Creating_DataSource/What_Are_Stores').
22

3-
The DataSource is intended to simplify working with data, whether it be an in-memory array, a local browser storage, remote service, or any custom storage. The DataSource is a stateful object that keeps sorting, grouping, filtering, and keeps data transformation properties and applies them each time data is loaded. It also provides [events](/api-reference/30%20Data%20Layer/DataSource/4%20Events '/Documentation/ApiReference/Data_Layer/DataSource/Events/') intended to handle changing data and the state.
3+
DataSource simplifies working with data, whether it be an in-memory array, a local browser storage, remote service, or any custom storage. DataSource is a stateful object that maintains sorting, grouping, filtering, and data transformation properties and applies them each time data is loaded. It also includes [events](/api-reference/30%20Data%20Layer/DataSource/4%20Events '/Documentation/ApiReference/Data_Layer/DataSource/Events/') intended to handle changing data and the state.
44

5-
The DataSource underlying data access logic is isolated in a Store. Unlike the DataSource, a Store is a stateless object implementing a universal interface for reading and modifying data. Each Store contains the same set of methods. For more information about Stores refer to the [What Are Stores](/concepts/70%20Data%20Binding/5%20Data%20Layer/1%20Creating%20DataSource/3%20What%20Are%20Stores.md '/Documentation/Guide/Data_Binding/Data_Layer/#Creating_DataSource/What_Are_Stores') section of this article.
5+
The DataSource's underlying data access logic is isolated in a Store. Unlike the DataSource, a Store is a stateless object that implements a universal interface to read and modify data. Each Store contains the same set of methods. For more information about Stores, refer to the [What Are Stores](/concepts/70%20Data%20Binding/5%20Data%20Layer/1%20Creating%20DataSource/3%20What%20Are%20Stores.md '/Documentation/Guide/Data_Binding/Data_Layer/#Creating_DataSource/What_Are_Stores') section of this article.
66

77
The following picture illustrates how the DataSource and Stores interact.
88

concepts/70 Data Binding/5 Data Layer/05 Asynchrony.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
##### jQuery
44

5-
All Data transferring operations in the data layer are asynchronous, whether it be an access to a remote service or to local data. It is made to support the universal Store interface, regardless of the source of data you access. These operations return a <a href="http://api.jquery.com/Types/#Promise" target="_blank">jQuery.Promise</a>. Use this Promise to specify callbacks for successful operation completion and for operation failure.
5+
All data transfer operations in the data layer are asynchronous for both remote services and local data access. This setup supports the universal Store interface for any data source. The data transfer operations return a <a href="http://api.jquery.com/Types/#Promise" target="_blank">jQuery.Promise</a>. Use this Promise to specify callbacks for successful operation completion and operation failure.
66

77
<!--JavaScript-->
88
dataSource.load()
@@ -15,7 +15,7 @@ All Data transferring operations in the data layer are asynchronous, whether it
1515

1616
##### Angular
1717

18-
All Data transferring operations in the data layer are asynchronous, whether it be an access to a remote service or to local data. It is made to support the universal Store interface, regardless of the source of data you access. These operations return a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" target="_blank">native Promise</a>. Use this Promise to specify callbacks for successful operation completion and for operation failure.
18+
All data transfer operations in the data layer are asynchronous for both remote services and local data access. This setup supports the universal Store interface for any data source. The data transfer operations return a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" target="_blank">native Promise</a>. Use this Promise to specify callbacks for successful operation completion and operation failure.
1919

2020
<!--JavaScript-->
2121
dataSource.load()
@@ -28,7 +28,7 @@ All Data transferring operations in the data layer are asynchronous, whether it
2828

2929
##### Vue
3030

31-
All Data transferring operations in the data layer are asynchronous, whether it be an access to a remote service or to local data. It is made to support the universal Store interface, regardless of the source of data you access. These operations return a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" target="_blank">native Promise</a>. Use this Promise to specify callbacks for successful operation completion and for operation failure.
31+
All data transfer operations in the data layer are asynchronous for both remote services and local data access. This setup supports the universal Store interface for any data source. The data transfer operations return a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" target="_blank">native Promise</a>. Use this Promise to specify callbacks for successful operation completion and operation failure.
3232

3333
<!--JavaScript-->
3434
dataSource.load()
@@ -41,7 +41,7 @@ All Data transferring operations in the data layer are asynchronous, whether it
4141

4242
##### React
4343

44-
All Data transferring operations in the data layer are asynchronous, whether it be an access to a remote service or to local data. It is made to support the universal Store interface, regardless of the source of data you access. These operations return a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" target="_blank">native Promise</a>. Use this Promise to specify callbacks for successful operation completion and for operation failure.
44+
All data transfer operations in the data layer are asynchronous for both remote services and local data access. This setup supports the universal Store interface for any data source. The data transfer operations return a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" target="_blank">native Promise</a>. Use this Promise to specify callbacks for successful operation completion and operation failure.
4545

4646
<!--JavaScript-->
4747
dataSource.load()

concepts/70 Data Binding/5 Data Layer/1 Creating DataSource/0 From Array.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Pass the required array to the DataSource constructor.
22

3-
<!--JavaScript-->var dataSource = new DevExpress.data.DataSource(array);
3+
<!--JavaScript-->const dataSource = new DevExpress.data.DataSource(array);
44

55
If you need to specify other DataSource [configuration properties](/api-reference/30%20Data%20Layer/DataSource/1%20Configuration '/Documentation/ApiReference/Data_Layer/DataSource/Configuration/'), use another form.
66

7-
<!--JavaScript-->var dataSource = new DevExpress.data.DataSource({
7+
<!--JavaScript-->const dataSource = new DevExpress.data.DataSource({
88
// array of data
99
store: array,
1010

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
If you pass a string to the DataSource constructor, the DataSource will access the data returned by the AJAX request to the URL specified by this string.
22

3-
<!--JavaScript-->var dataSource = new DevExpress.data.DataSource("http://www.example.com/dataservices/jsondata");
3+
<!--JavaScript-->const dataSource = new DevExpress.data.DataSource("http://www.example.com/dataservices/jsondata");
44

5-
You may also use a JSONP callback parameter.
5+
You can also use a JSONP callback parameter.
66

7-
<!--JavaScript-->var dataSource = new DevExpress.data.DataSource("http://www.example.com/dataservices/jsonpdata?callback=?");
7+
<!--JavaScript-->const dataSource = new DevExpress.data.DataSource("http://www.example.com/dataservices/jsonpdata?callback=?");
88

99
#####See Also#####
1010
- [Load Data in Raw Mode](/concepts/70%20Data%20Binding/51%20Data%20Source%20Examples/3%20Custom%20Sources/1%20Load%20Data%20in%20Raw%20Mode.md '/Documentation/Guide/Data_Binding/Data_Source_Examples/#Custom_Sources/Load_Data_in_Raw_Mode')

concepts/70 Data Binding/5 Data Layer/1 Creating DataSource/2 From Store.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
Pass a Store instance to the DataSource constructor.
22

3-
<!--JavaScript-->var store = new DevExpress.data.ArrayStore(data);
4-
var dataSource = new DevExpress.data.DataSource(store);
3+
<!--JavaScript-->const store = new DevExpress.data.ArrayStore(data);
4+
const dataSource = new DevExpress.data.DataSource(store);
55

6-
If you need to specify other DataSource [properties](/api-reference/30%20Data%20Layer/DataSource/1%20Configuration '/Documentation/ApiReference/Data_Layer/DataSource/Configuration/'), use the following code.
6+
If you need to specify other DataSource [properties](/api-reference/30%20Data%20Layer/DataSource/1%20Configuration '/Documentation/ApiReference/Data_Layer/DataSource/Configuration/'), use the following code:
77

8-
<!--JavaScript-->var store = new DevExpress.data.ArrayStore(array);
9-
var dataSource = new DevExpress.data.DataSource({
8+
<!--JavaScript-->const store = new DevExpress.data.ArrayStore(array);
9+
const dataSource = new DevExpress.data.DataSource({
1010
sort: "name",
1111
pageSize: 10,
1212
store: store
1313
});
1414

1515
In this example, the Store instance is passed to the [store](/api-reference/30%20Data%20Layer/DataSource/1%20Configuration/store '/Documentation/ApiReference/Data_Layer/DataSource/Configuration/#store') configuration property.
1616

17-
A Store can be specified implicitly. Two possibilities are described above ([From Array](/concepts/70%20Data%20Binding/5%20Data%20Layer/1%20Creating%20DataSource/0%20From%20Array.md '/Documentation/Guide/Data_Binding/Data_Layer/#Creating_DataSource/From_Array') and [From Url](/concepts/70%20Data%20Binding/5%20Data%20Layer/1%20Creating%20DataSource/1%20From%20url.md '/Documentation/Guide/Data_Binding/Data_Layer/#Creating_DataSource/From_url')). In addition, you can use the following.
17+
A Store can be specified implicitly. Two methods are described above ([From Array](/concepts/70%20Data%20Binding/5%20Data%20Layer/1%20Creating%20DataSource/0%20From%20Array.md '/Documentation/Guide/Data_Binding/Data_Layer/#Creating_DataSource/From_Array') and [From Url](/concepts/70%20Data%20Binding/5%20Data%20Layer/1%20Creating%20DataSource/1%20From%20url.md '/Documentation/Guide/Data_Binding/Data_Layer/#Creating_DataSource/From_url')). You can also use the following methods:
1818

1919
- Add the properties implementing the required data access logic to the DataSource configuration object. In this case, the [CustomStore](/api-reference/30%20Data%20Layer/CustomStore '/Documentation/ApiReference/Data_Layer/CustomStore/') will be automatically created within the DataSource. The properties should correspond to the [CustomStore configuration properties](/api-reference/30%20Data%20Layer/CustomStore/1%20Configuration '/Documentation/ApiReference/Data_Layer/CustomStore/Configuration/').
2020

21-
<!--JavaScript-->var dataSource = new DevExpress.data.DataSource({
21+
<!--JavaScript-->const dataSource = new DevExpress.data.DataSource({
2222
//DataSource configuration
2323
sort: "name",
2424
pageSize: 10,
@@ -32,9 +32,9 @@ A Store can be specified implicitly. Two possibilities are described above ([Fro
3232
...
3333
});
3434

35-
- Pass a Store configuration object. Besides the required Store configuration properties, this object should contain the **type** property that specifies which Store object will be created within the DataSource.
35+
- Pass a Store configuration object. This object should include the required Store configuration properties and the **type** property. **type** specifies which Store object will be created within the DataSource.
3636

37-
<!--JavaScript-->var dataSource = new DevExpress.data.DataSource({
37+
<!--JavaScript-->const dataSource = new DevExpress.data.DataSource({
3838
store: {
3939
type: "array",
4040
data: array
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
To create a [DataSource](/api-reference/30%20Data%20Layer/DataSource '/Documentation/ApiReference/Data_Layer/DataSource/') instance, call the DataSource constructor and pass the required [configuration object](/api-reference/30%20Data%20Layer/DataSource/1%20Configuration '/Documentation/ApiReference/Data_Layer/DataSource/Configuration/') to this constructor. This section covers the ways to associate the required data with the DataSource instance being created. You can use one of these properties to create a DataSource instance.
1+
To create a [DataSource](/api-reference/30%20Data%20Layer/DataSource '/Documentation/ApiReference/Data_Layer/DataSource/') instance, call the DataSource constructor and pass the required [configuration object](/api-reference/30%Data%20Layer/DataSource/1%Configuration '/Documentation/ApiReference/Data_Layer/DataSource/Configuration/'). This section explains how to link the required data with the new DataSource instance. Use one of the following properties to create the DataSource instance.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
By default, the DataSource loads items by pages. Page size is determined by the [pageSize](/api-reference/30%20Data%20Layer/DataSource/1%20Configuration/pageSize.md '/Documentation/ApiReference/Data_Layer/DataSource/Configuration/#pageSize') configuration property of the DataSource.
1+
DataSource loads items by pages. The [pageSize](/api-reference/30%20Data%20Layer/DataSource/1%20Configuration/pageSize.md '/Documentation/ApiReference/Data_Layer/DataSource/Configuration/#pageSize') configuration property determines the page size.
22

33
<!--JavaScript-->
4-
var dataSource = new DevExpress.data.DataSource({
4+
const dataSource = new DevExpress.data.DataSource({
55
pageSize: 30,
66
. . .
77
});
88

9-
The current page index can be accessed and modified via the [pageIndex()](/api-reference/30%20Data%20Layer/DataSource/3%20Methods/pageIndex().md '/Documentation/ApiReference/Data_Layer/DataSource/Methods/#pageIndex') and [pageIndex(newIndex)](/api-reference/30%20Data%20Layer/DataSource/3%20Methods/pageIndex(newIndex).md '/Documentation/ApiReference/Data_Layer/DataSource/Methods/#pageIndexnewIndex') methods respectively.
9+
Access and change the current page index with the [pageIndex()](/api-reference/30%20Data%20Layer/DataSource/3%20Methods/pageIndex().md '/Documentation/ApiReference/Data_Layer/DataSource/Methods/#pageIndex') and [pageIndex(newIndex)](/api-reference/30%20Data%20Layer/DataSource/3%20Methods/pageIndex(newIndex).md '/Documentation/ApiReference/Data_Layer/DataSource/Methods/#pageIndexnewIndex') methods.
1010

1111
<!--JavaScript-->
1212
dataSource.pageIndex(1); // Switch to the next page
@@ -15,7 +15,7 @@ The current page index can be accessed and modified via the [pageIndex()](/api-r
1515
To disable paging, assign **false** to the [paginate](/api-reference/30%20Data%20Layer/DataSource/1%20Configuration/paginate.md '/Documentation/ApiReference/Data_Layer/DataSource/Configuration/#paginate') configuration property of the [DataSource](/api-reference/30%20Data%20Layer/DataSource '/Documentation/ApiReference/Data_Layer/DataSource/').
1616

1717
<!--JavaScript-->
18-
var dataSource = new DevExpress.data.DataSource({
18+
const dataSource = new DevExpress.data.DataSource({
1919
paginate: false,
2020
. . .
2121
});

concepts/70 Data Binding/5 Data Layer/2 Reading Data/1 Sorting.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[DataSources](/api-reference/30%20Data%20Layer/DataSource '/Documentation/ApiReference/Data_Layer/DataSource/') and [Stores](/concepts/70%20Data%20Binding/5%20Data%20Layer/1%20Creating%20DataSource/3%20What%20Are%20Stores.md '/Documentation/Guide/Data_Binding/Data_Layer/#Creating_DataSource/What_Are_Stores') use sort expressions to specify sorting conditions and direction.
22

3-
For an example, declare a **Person** class.
3+
For example, declare a **Person** class:
44

5-
<!--JavaScript-->var Person = function(firstName, lastName, city) {
5+
<!--JavaScript-->const Person = function(firstName, lastName, city) {
66
this.firstName = firstName;
77
this.lastName = lastName;
88
this.address = {
@@ -13,20 +13,20 @@ For an example, declare a **Person** class.
1313
return this.firstName + " " + this.lastName;
1414
};
1515

16-
After the **Person** class is created, declare a **data** array holding several instances of this class.
16+
Declare a **data** array with multiple instances of the **Person** class:
1717

18-
<!--JavaScript-->var data = [
18+
<!--JavaScript-->const data = [
1919
new Person("John", "Smith", "San Francisco"),
2020
new Person("John", "Doe", "New York"),
2121
new Person("Xavier", "Gomez", "Denver"),
2222
new Person("Xavier", "Lee", "New Mexico")
2323
];
2424

25-
Create a simple [DataSource](/api-reference/30%20Data%20Layer/DataSource '/Documentation/ApiReference/Data_Layer/DataSource/').
25+
Create [DataSource](/api-reference/30%20Data%20Layer/DataSource '/Documentation/ApiReference/Data_Layer/DataSource/'):
2626

27-
<!--JavaScript-->var dataSource = new DevExpress.data.DataSource(data);
27+
<!--JavaScript-->const dataSource = new DevExpress.data.DataSource(data);
2828

29-
The sorting condition can be specified using the [sort](/api-reference/30%20Data%20Layer/DataSource/1%20Configuration/sort.md '/Documentation/ApiReference/Data_Layer/DataSource/Configuration/#sort') configuration property or the [sort(sortExpr)](/api-reference/30%20Data%20Layer/DataSource/3%20Methods/sort(sortExpr).md '/Documentation/ApiReference/Data_Layer/DataSource/Methods/#sortsortExpr') method of the DataSource. The value assigned to the property or passed to the method is a sorting expression, which can have one of the following formats.
29+
Specify the sorting condition with the [sort](/api-reference/30%20Data%20Layer/DataSource/1%20Configuration/sort.md '/Documentation/ApiReference/Data_Layer/DataSource/Configuration/#sort') configuration property or the [sort(sortExpr)](/api-reference/30%20Data%20Layer/DataSource/3%20Methods/sort(sortExpr).md '/Documentation/ApiReference/Data_Layer/DataSource/Methods/#sortsortExpr') method of the DataSource. You can pass a sorting expression to the property/method in one of the following formats:
3030

3131
- **A single expression**
3232

@@ -35,7 +35,7 @@ The sorting condition can be specified using the [sort](/api-reference/30%20Data
3535
// 'result' contains the 'data' array items sorted by 'lastName'
3636
});
3737

38-
To sort data in descending order, pass an object containing the **getter** (**field** or **selector** - they are equivalents) and **desc** properties to the sort method.
38+
To sort data in descending order, pass an object containing the **getter** (**field** or **selector** - they are equivalents) and **desc** properties to the sort method:
3939

4040
<!--JavaScript-->dataSource.sort({ getter: "lastName", desc: true });
4141
dataSource.load().done(function(result) {
@@ -66,7 +66,7 @@ The sorting condition can be specified using the [sort](/api-reference/30%20Data
6666
// 'result' contains the 'data' array items sorted by 'fullName' and then by 'address.city' in the descending order
6767
});
6868

69-
You can pass an array of expressions instead of using several arguments.
69+
You can pass an array of expressions instead of using multiple arguments.
7070

7171
<!--JavaScript-->dataSource.sort([
7272
"firstName",
@@ -80,7 +80,7 @@ The sorting condition can be specified using the [sort](/api-reference/30%20Data
8080

8181
[Stores](/concepts/70%20Data%20Binding/5%20Data%20Layer/1%20Creating%20DataSource/3%20What%20Are%20Stores.md '/Documentation/Guide/Data_Binding/Data_Layer/#Creating_DataSource/What_Are_Stores') support the same sort expression syntax as the [DataSource](/api-reference/30%20Data%20Layer/DataSource '/Documentation/ApiReference/Data_Layer/DataSource/').
8282

83-
<!--JavaScript-->var arrayStore = new DevExpress.data.ArrayStore(data);
83+
<!--JavaScript-->const arrayStore = new DevExpress.data.ArrayStore(data);
8484
arrayStore
8585
.load({
8686
sort: [

0 commit comments

Comments
 (0)