Methods
This section describes the methods used to manipulate the DataSource.
cancel(operationId)
Cancels the load operation with a specific identifier.
true if operation is canceled; false if it was not found.
You can access the load operation identifier using the operationId field extending the Promise object returned by the load() or reload() method.
var loadPromise = dataSource.load(); loadPromise.done(function(result) { . . . }); . . . dataSource.cancel(loadPromise.operationId);
dispose()
Disposes all resources associated with this DataSource.
Use this method only if you created the DataSource manually (not via a widget).
isLastPage()
Checks whether the count of items on the current page is less than the pageSize. Takes effect only with enabled paging.
true if the item count is less than the pageSize; otherwise false.
isLoaded()
Checks whether data is loaded in the DataSource.
true if data is loaded; otherwise false.
isLoading()
Checks whether the DataSource is being loaded.
true if the DataSource is being loaded; otherwise false.
key()
Gets the value of the underlying Store's key option.
This method is actually a shortcut to the key option of the underlying Store. Using this method is equivalent to using dataSource.store().key().
See Also
- key in ArrayStore | CustomStore | LocalStore | ODataStore
load()
Starts loading data.
A Promise that is resolved after the data is loaded. It is a native Promise or a jQuery.Promise when you use jQuery.
Use the following code to access the loaded data.
dataSource.load() .done(function(result) { // 'result' contains the loaded data }) .fail(function(error) { // handle error });
The Promise object returned by the load() method is extended by the operationId field. Pass its value to the cancel(operationId) method to cancel the invoked operation.
var loadPromise = dataSource.load(); loadPromise.done(function(result) { . . . }); . . . dataSource.cancel(loadPromise.operationId);
loadOptions()
Returns an object that would be passed to the load() method of the underlying Store according to the current data shaping option values of the current DataSource instance.
A data shaping configuration object.
off(eventName)
Detaches all event handlers from a single event.
The event's name.
The object for which this method is called.
See Also
- Handle Events: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
off(eventName, eventHandler)
Detaches a particular event handler from a single event.
The object for which this method is called.
See Also
- Handle Events: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
on(eventName, eventHandler)
Subscribes to an event.
The object for which this method is called.
on(events)
Subscribes to events.
Events with their handlers: { "eventName1": handler1, "eventName2": handler2, ...}
The object for which this method is called.
pageIndex(newIndex)
Sets the index of the page that should be loaded on the next call of the load() method.
A zero-based page index.
reload()
Clears currently loaded DataSource items and calls the load() method.
A Promise that is resolved after loading is completed and rejected after loading failed. It is a native Promise or a jQuery.Promise when you use jQuery.
The Promise object returned by the reload() method is extended by the operationId field. Pass its value to the cancel(operationId) method to cancel the invoked operation.
var reloadPromise = dataSource.reload(); reloadPromise.done(function(result) { . . . }); . . . dataSource.cancel(reloadPromise.operationId);
searchExpr()
Gets the searchExpr option's value.
The option's value; described in the Getters and Setters section.
See Also
searchExpr(expr)
Sets the searchExpr option's value.
A new value; described in the Getters and Setters section.
dataSource.searchExpr("firstName"); dataSource.searchOperation("contains"); dataSource.searchValue("Jo");
See Also
searchOperation()
Gets the searchOperation option's value.
The option's value.
For more information on searching, refer to the Search Api section of the Data Layer article.
searchOperation(op)
Sets the searchOperation option's value.
A new value. Can be one of the following: "=", "<>", ">", ">=", "<", "<=", "startswith", "endswith", "contains" and "notcontains".
dataSource.searchExpr("firstName"); dataSource.searchOperation("contains"); dataSource.searchValue("Jo");
See Also
searchValue()
Gets the searchValue option's value.
The option's value.
For more information on searching, refer to the Search Api section of the Data Layer article.
searchValue(value)
Sets the searchValue option's value.
A new value.
dataSource.searchValue("Jo");
For more information on searching, refer to the Search Api section of the Data Layer article.
select()
Gets the select option's value.
The current select expression; described in the Select Expressions section.
select(expr)
Sets the select option's value.
A select expression; described in the Select Expressions section.
dataSource.select("firstName", "lastName", "age");
sort()
Gets the sort option's value.
The current sort expression; described in the Sorting section.
sort(sortExpr)
Sets the sort option's value.
A sort expression; described in the Sorting section.
dataSource.sort("firstName");
totalCount()
Returns the number of data items available in an underlying Store after the last load() operation without paging.
The number of items.
To use this method, set the requireTotalCount option to true.