This section describes properties that configure the DataSource.
The DataSource allows you to specify CustomStore properties in its configuration object. If you define CustomStore properties as shown in the following code, they override the store.
jQueryvar infiniteList = new DevExpress.data.DataSource({ load: function (loadOptions) { // Loading data objects }, byKey: function (key) { // Retrieving a data object by key } });Angular
import DataSource from "devextreme/data/data_source"; // ... export class AppComponent { infiniteList: DataSource; constructor() { this.infiniteList = new DataSource({ load: (loadOptions) => { return new Promise((resolve, reject) => { const data = // Loading data objects resolve(data); }); }, byKey: (key) => { return new Promise((resolve, reject) => { const obj = // Retrieving a data object by key resolve(obj); }); } }); } }Vue
<script> import DataSource from 'devextreme/data/data_source'; const infiniteList = new DataSource({ load: (loadOptions) => { // Loading data objects }, byKey: (key) => { // Retrieving a data object by key } }); export default { // ... data() { return { infiniteList } } } </script>React
// ... import DataSource from 'devextreme/data/data_source'; const infiniteList = new DataSource({ load: (loadOptions) => { // Loading data objects }, byKey: (key) => { // Retrieving a data object by key } }); class App extends React.Component { // ... } export default App;
Custom parameters that should be passed to an OData service with the load query. Available only for the ODataStore.
jQueryvar ds = new DevExpress.data.DataSource({ store: { type: "odata", // ODataStore is configured here }, customQueryParams: { param: "value" } });Angular
import DataSource from "devextreme/data/data_source"; import ODataStore from "devextreme/data/odata/store"; // ... export class AppComponent { ds: DataSource; constructor() { this.ds = new DataSource({ store: new ODataStore({ // ODataStore is configured here }), customQueryParams: { param: "value" } }); } }Vue
<script> import DataSource from 'devextreme/data/data_source'; import ODataStore from 'devextreme/data/odata/store'; const ds = new DataSource({ store: new ODataStore({ // ODataStore is configured here }), customQueryParams: { param: 'value' } }); export default { // ... data() { return { ds } } } </script>React
// ... import DataSource from 'devextreme/data/data_source'; import ODataStore from 'devextreme/data/odata/store'; const ds = new DataSource({ store: new ODataStore({ // ODataStore is configured here }), customQueryParams: { param: 'value' } }); class App extends React.Component { // ... } export default App;See Also
Specifies the navigation properties to be loaded with the OData entity. Available only for the ODataStore.
jQueryvar ds = new DevExpress.data.DataSource({ store: { type: "odata", // ODataStore is configured here }, expand: ["PropertyName1", "PropertyName2"] });Angular
import DataSource from "devextreme/data/data_source"; import ODataStore from "devextreme/data/odata/store"; // ... export class AppComponent { ds: DataSource; constructor() { this.ds = new DataSource({ store: new ODataStore({ // ODataStore is configured here }), expand: ["PropertyName1", "PropertyName2"] }); } }Vue
<script> import DataSource from 'devextreme/data/data_source'; import ODataStore from 'devextreme/data/odata/store'; const ds = new DataSource({ store: new ODataStore({ // ODataStore is configured here }), expand: ['PropertyName1', 'PropertyName2'] }); export default { // ... data() { return { ds } } } </script>React
// ... import DataSource from 'devextreme/data/data_source'; import ODataStore from 'devextreme/data/odata/store'; const ds = new DataSource({ store: new ODataStore({ // ODataStore is configured here }), expand: ['PropertyName1', 'PropertyName2'] }); class App extends React.Component { // ... } export default App;ASP.NET MVC Controls
@(Html.DevExtreme().WidgetName() .DataSource(ds => ds.OData() .Expand("PropertyName1", "PropertyName2") ) )
@(Html.DevExtreme().WidgetName() _ .DataSource(Function(ds) Return ds.OData() _ .Expand("PropertyName1", "PropertyName2") End Function) )See Also
Specifies data filtering conditions.
Possible variants:
Binary filter
Supported operators: "=", "<>", ">", ">=", "<", "<=", "startswith", "endswith", "contains", "notcontains".
Example:
Unary filter
Supported operators: binary operators, "!".
Example:
[ "!", [ "dataField", "=", 3 ] ]
Complex filter
Supported operators: binary and unary operators, "and", "or".
Example:
[ [ "dataField", "=", 10 ], "and", [ [ "anotherDataField", "<", 3 ], "or", [ "anotherDataField", ">", 11 ] ] ]
var ds = new DevExpress.data.DataSource({ // ... filter: [ "count", "<", "10" ] });Angular
import DataSource from "devextreme/data/data_source"; // ... export class AppComponent { ds: DataSource; constructor() { this.ds = new DataSource({ // ... filter: [ "count", "<", "10" ] }); } }Vue
<script> import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... filter: [ 'count', '<', '10' ] }); export default { // ... data() { return { ds } } } </script>React
// ... import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... filter: [ 'count', '<', '10' ] }); class App extends React.Component { // ... } export default App;ASP.NET MVC Controls
@(Html.DevExtreme().WidgetName() .DataSourceOptions(dso => dso .Filter("[ 'count', '<', '10' ]") ) )
Filtering works when inputting a plain data structure only. However, if you need the filtering capability and hierarchical data, transform the plain data using the
DataSource's
groupproperty.
See AlsoSpecifies data grouping properties.
This property accepts one of the following:
String
The field name to group by.
Object
An object with the following fields:
Array
An array of strings and objects described above.
Function
A function that returns the value to group by.
var ds = new DevExpress.data.DataSource({ // ... group: { selector: "LastName", desc: true }, /* or as a function group: function(e) { // creates two custom groups return e.BirthYear < 1990 ? "Born before 1990" : "Born after 1990"; } */ });Angular
import DataSource from "devextreme/data/data_source"; // ... export class AppComponent { ds: DataSource; constructor() { this.ds = new DataSource({ // ... group: { selector: "LastName", desc: true }, /* or as a function group: function(e) { // creates two custom groups return e.BirthYear < 1990 ? "Born before 1990" : "Born after 1990"; } */ }); } }Vue
<script> import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... group: { selector: 'LastName', desc: true }, /* or as a function group: function(e) { // creates two custom groups return e.BirthYear < 1990 ? 'Born before 1990' : 'Born after 1990'; } */ }); export default { // ... data() { return { ds } } } </script>React
// ... import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... group: { selector: 'LastName', desc: true }, /* or as a function group: function(e) { // creates two custom groups return e.BirthYear < 1990 ? 'Born before 1990' : 'Born after 1990'; } */ }); class App extends React.Component { // ... } export default App;ASP.NET MVC Controls
@(Html.DevExtreme().WidgetName() .DataSourceOptions(dso => dso .Group("LastName", true) // === or as a function === .Group("group_function") ) ) <script type="text/javascript"> function group_function(e) { // creates two custom groups return e.BirthYear < 1990 ? "Born before 1990" : "Born after 1990"; } </script>See Also
Specifies parameters for language-specific sorting and filtering.
Use this property to include language-specific parameters in sorting and filtering operations performed on a client. For example, you can use langParams to make DataSource ignore letters with diacritic symbols. Specify locale and collator options as in the example below:
jQueryconst dataSource = new DevExpress.data.DataSource({ // ... langParams: { locale: 'fr', collatorOptions: { sensitivity: 'accent', caseFirst: 'upper' } } });Angular
import DataSource from "devextreme/data/data_source"; // ... export class AppComponent { dataSource: DataSource; constructor () { this.dataSource = new DataSource({ // ... langParams: { locale: 'fr', collatorOptions: { sensitivity: 'accent', caseFirst: 'upper' } } }); } }Vue
<script> import DataSource from 'devextreme/data/data_source'; const dataSource = new DataSource({ // ... langParams: { locale: 'fr', collatorOptions: { sensitivity: 'accent', caseFirst: 'upper' } } }); export default { data() { return { dataSource } } } </script>React
// ... import DataSource from 'devextreme/data/data_source'; const dataSource = new DataSource({ // ... langParams: { locale: 'fr', collatorOptions: { sensitivity: 'accent', caseFirst: 'upper' } } }); function App() { // ... } export default App;
Specifies an item mapping function.
jQueryvar ds = new DevExpress.data.DataSource({ store: { data: [{ firstName: "John", lastName: "Smith" }] }, map: function (dataItem) { return { fullName: dataItem.firstName + " " + dataItem.lastName } } });Angular
import DataSource from "devextreme/data/data_source"; import ArrayStore from "devextreme/data/array_store"; // ... export class AppComponent { ds: DataSource; constructor() { this.ds = new DataSource({ store: new ArrayStore({ data: [{ firstName: "John", lastName: "Smith" }] }), map: (dataItem) => { return { fullName: dataItem.firstName + " " + dataItem.lastName } } }); } }Vue
<script> import DataSource from 'devextreme/data/data_source'; import ArrayStore from 'devextreme/data/array_store'; const ds = new DataSource({ store: new ArrayStore({ data: [{ firstName: 'John', lastName: 'Smith' }] }), map: (dataItem) => { return { fullName: dataItem.firstName + ' ' + dataItem.lastName } } }); export default { // ... data() { return { ds } } } </script>React
// ... import DataSource from 'devextreme/data/data_source'; import ArrayStore from 'devextreme/data/array_store'; const ds = new DataSource({ store: new ArrayStore({ data: [{ firstName: 'John', lastName: 'Smith' }] }), map: (dataItem) => { return { fullName: dataItem.firstName + ' ' + dataItem.lastName } } }); class App extends React.Component { // ... } export default App;ASP.NET MVC Controls
@(Html.DevExtreme().WidgetName() .DataSource(new [] { new { firstName = "John", lastName = "Smith" } }) .DataSourceOptions(dso => dso .Map("dataSource_map") ) ) <script type="text/javascript"> function dataSource_map (dataItem) { return { fullName: dataItem.firstName + " " + dataItem.lastName } } </script>See Also
A function that is executed after data is loaded.
Function parameters:Information about changes.
Appears only when the push(changes) method is called and the reshapeOnPush property is false.
Object structure:
Name Type Description changesArray<any>
The received changes.
jQueryvar ds = new DevExpress.data.DataSource({ onChanged: function () { // Your code goes here } });Angular
import DataSource from "devextreme/data/data_source"; // ... export class AppComponent { ds: DataSource; constructor() { this.ds = new DataSource({ onChanged: () => { // Your code goes here } }); } }Vue
<script> import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... onChanged: () => { // Your code goes here } }); export default { // ... data() { return { ds } } } </script>React
// ... import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... onChanged: () => { // Your code goes here } }); class App extends React.Component { // ... } export default App;
A function that is executed when data loading fails.
Function parameters:The error.
Object structure:
Name Type Description messageThe error message.
jQueryvar ds = new DevExpress.data.DataSource({ onLoadError: function (error) { console.log(error.message); } });Angular
import DataSource from "devextreme/data/data_source"; // ... export class AppComponent { ds: DataSource; constructor() { this.ds = new DataSource({ onLoadError: (error) => { console.log(error.message); } }); } }Vue
<script> import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... onLoadError: (error) => { console.log(error.message); } }); export default { // ... data() { return { ds } } } </script>React
// ... import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... onLoadError: (error) => { console.log(error.message); } }); class App extends React.Component { // ... } export default App;
A function that is executed when the data loading status changes.
Function parameters:Indicates whether data is being loaded.
jQueryvar ds = new DevExpress.data.DataSource({ onLoadingChanged: function (isLoading) { // Your code goes here } });Angular
import DataSource from "devextreme/data/data_source"; // ... export class AppComponent { ds: DataSource; constructor() { this.ds = new DataSource({ onLoadingChanged: (isLoading) => { // Your code goes here } }); } }Vue
<script> import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... onLoadingChanged: (isLoading) => { // Your code goes here } }); export default { // ... data() { return { ds } } } </script>React
// ... import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... onLoadingChanged: (isLoading) => { // Your code goes here } }); class App extends React.Component { // ... } export default App;
Specifies the maximum number of data items per page. Applies only if paginate is true.
When data is grouped, this property specifies the number of groups per page. However, in the DataGrid and TreeList, it specifies the number of rows per page including group rows.
Specifies whether the DataSource loads data items by pages or all at once. Defaults to false if group is set; otherwise, true.
Specifies a post processing function.
Function parameters:Data loaded in the DataSource.
jQueryvar ds = new DevExpress.data.DataSource({ postProcess: function (data) { // Your code goes here } });Angular
import DataSource from "devextreme/data/data_source"; // ... export class AppComponent { ds: DataSource; constructor() { this.ds = new DataSource({ postProcess: (data) => { // Your code goes here } }); } }Vue
<script> import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... postProcess: (data) => { // Your code goes here } }); export default { // ... data() { return { ds } } } </script>React
// ... import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... postProcess: (data) => { // Your code goes here } }); class App extends React.Component { // ... } export default App;ASP.NET MVC Controls
@(Html.DevExtreme().WidgetName() .DataSourceOptions(dso => dso .PostProcess("dataSource_postProcess") ) ) <script type="text/javascript"> function dataSource_postProcess (data) { // Your code goes here } </script>
When the
paginateproperty is enabled, the
postProcessfunction handles only data available for the selected page. If you need to access all data, process data before it is passed to the store.
See AlsoSpecifies the period (in milliseconds) when changes are aggregated before pushing them to the DataSource.
Specifies whether the DataSource requests the total count of data items in the storage.
If this property is set to true, the Promise that the load() method returns is resolved with a second argument that contains the totalCount field:
jQueryvar ds = new DevExpress.data.DataSource({ // ... requireTotalCount: true }); ds.load() .done(function (data, extra) { // "data" contains the loaded data // "extra" contains the "totalCount" field });
When
scrollingis infinite in the DataGrid, this property's value is always
false.
Specifies whether to reapply sorting, filtering, grouping, and other data processing operations after receiving a push.
Specifies the fields to search.
In most cases, you should pass the name of a field by whose value data items are searched. Assign an array of field names to this property if you need to search elements by several field values.
jQueryvar ds = new DevExpress.data.DataSource({ // ... searchExpr: ["firstName", "lastName"] });Angular
import DataSource from "devextreme/data/data_source"; // ... export class AppComponent { ds: DataSource; constructor() { this.ds = new DataSource({ // ... searchExpr: ["firstName", "lastName"] }); } }Vue
<script> import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... searchExpr: ['firstName', 'lastName'] }); export default { // ... data() { return { ds } } } </script>React
// ... import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... searchExpr: ['firstName', 'lastName'] }); class App extends React.Component { // ... } export default App;
You can use this property along with searchOperation and searchValue to specify a simple filter. Use the filter property for more complex filtering conditions. Filters are combined if you specify them in both ways.
Searching works when inputting a plain data structure only. However, if you need the searching capability and hierarchical data, transform the plain data using the
DataSource's
groupproperty.
See AlsoSpecifies the comparison operation used in searching.
Default Value: 'contains'
Specifies the value to which the search expression is compared.
Type: any
Default Value: null
Specifies the fields to select from data objects.
This property accepts one of the following:
String
A field name to select.
Array of strings
Several field names to select.
Function
A function implementing custom selection logic.
var ds = new DevExpress.data.DataSource({ // ... select: ["firstName", "lastName", "birthDate"] });Angular
import DataSource from "devextreme/data/data_source"; // ... export class AppComponent { ds: DataSource; constructor() { this.ds = new DataSource({ // ... select: ["firstName", "lastName", "birthDate"] }); } }Vue
<script> import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... select: ['firstName', 'lastName', 'birthDate'] }); export default { // ... data() { return { ds } } } </script>React
// ... import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... select: ['firstName', 'lastName', 'birthDate'] }); class App extends React.Component { // ... } export default App;ASP.NET MVC Controls
@(Html.DevExtreme().WidgetName() .DataSourceOptions(dso => dso .Select("firstName", "lastName", "birthDate") ) )See Also
Specifies data sorting properties.
This property accepts one of the following:
String
The field name to sort by.
Object
An object with the following fields:
Array
An array of strings and objects described above.
Function
A function that returns the value to sort by.
var ds = new DevExpress.data.DataSource({ // ... sort: [ "Position", { selector: "Last_Name", desc: true } ], /* or as a function sort: function(e) { // CEOs are always displayed at the top if(e.Position == "CEO") return "!"; else return e.Position; } */ });Angular
import DataSource from "devextreme/data/data_source"; // ... export class AppComponent { ds: DataSource; constructor() { this.ds = new DataSource({ // ... sort: [ "Position", { selector: "Last_Name", desc: true } ], /* or as a function sort: function(e) { // CEOs are always displayed at the top if(e.Position == "CEO") return "!"; else return e.Position; } */ }); } }Vue
<script> import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... sort: [ 'Position', { selector: 'Last_Name', desc: true } ], /* or as a function sort: function(e) { // CEOs are always displayed at the top if(e.Position == 'CEO') return '!'; else return e.Position; } */ }); export default { // ... data() { return { ds } } } </script>React
// ... import DataSource from 'devextreme/data/data_source'; const ds = new DataSource({ // ... sort: [ 'Position', { selector: 'Last_Name', desc: true } ], /* or as a function sort: function(e) { // CEOs are always displayed at the top if(e.Position == 'CEO') return '!'; else return e.Position; } */ }); class App extends React.Component { // ... } export default App;ASP.NET MVC Controls
@(Html.DevExtreme().WidgetName() .DataSourceOptions(dso => dso .Sort("Position", true) // for sorting by a single field // === or === .Sort("sort_function") // === or === .Sort(s => { // for sorting by multiple fields s.AddSorting("Position"); s.AddSorting("Last_Name", true); }) ) ) <script type="text/javascript"> function sort_function(e) { // CEOs are always displayed at the top if(e.Position == "CEO") return "!"; else return e.Position; } </script>
@(Html.DevExtreme().WidgetName() _ .DataSourceOptions(Sub(dso) dso.Sort("Position", True) ' for sorting by a single field ' === or === dso.Sort("sort_function") ' === or === dso.Sort(Sub(s) ' for sorting by multiple fields s.AddSorting("Position") s.AddSorting("Last_Name", True) End Sub) End Sub) ) <script type="text/javascript"> function sort_function(e) { // CEOs are always displayed at the top if(e.Position == "CEO") return "!"; else return e.Position; } </script>See Also
Configures the store underlying the DataSource.
This property accepts one of the following:
Store instance
An ArrayStore, LocalStore, ODataStore, or CustomStore instance.
Store configuration object
An ArrayStore, LocalStore, or ODataStore configuration object. Make sure to set the type property.
Array
Assigning an array to the store property automatically creates an ArrayStore in the DataSource.
var ds = new DevExpress.data.DataSource({ store: new DevExpress.data.ArrayStore({ // ArrayStore instance }) // ===== or ===== store: { type: "array", // ArrayStore configuration object } // ===== or ===== store: [ { id: 1, name: "John Doe" } ] });Angular
import DataSource from "devextreme/data/data_source"; import ArrayStore from "devextreme/data/array_store"; // ... export class AppComponent { ds: DataSource; constructor() { this.ds = new DataSource({ store: new ArrayStore({ // ArrayStore instance }) // ===== or ===== store: { type: "array", // ArrayStore configuration object } // ===== or ===== store: [ { id: 1, name: "John Doe" } ] }); } }Vue
<script> import DataSource from 'devextreme/data/data_source'; import ArrayStore from 'devextreme/data/array_store'; const ds = new DataSource({ store: new ArrayStore({ // ArrayStore instance }) // ===== or ===== store: { type: 'array', // ArrayStore configuration object } // ===== or ===== store: [ { id: 1, name: 'John Doe' } ] }); export default { // ... data() { return { ds } } } </script>React
// ... import DataSource from 'devextreme/data/data_source'; import ArrayStore from 'devextreme/data/array_store'; const ds = new DataSource({ store: new ArrayStore({ // ArrayStore instance }) // ===== or ===== store: { type: 'array', // ArrayStore configuration object } // ===== or ===== store: [ { id: 1, name: 'John Doe' } ] }); class App extends React.Component { // ... } export default App;Feel free to share topic-related thoughts here.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4