In This Topic
ODataVirtualCollectionView Class
In This Topic
File
wijmo.odata.js
Module
wijmo.odata
Base Class
ODataCollectionView

Extends the ODataCollectionView class to support loading data on demand, using the setWindow method.

The example below shows how you can declare an ODataCollectionView and synchronize it with a FlexGrid control to load the data that is within the grid's viewport:

// declare virtual collection view
let view = new wijmo.odata.ODataVirtualCollectionView(url, 'Order_Details_Extendeds', {
    oDataVersion: 4
});

// use virtual collection as grid data source flex.itemsSource = view;
// update data window when the grid scrolls flex.scrollPositionChanged.addHandler(() => { let rng = flex.viewRange; view.setWindow(rng.topRow, rng.bottomRow); });

The ODataVirtualCollectionView class implements a 'data window' so only data that is actually being displayed is loaded from the server. Items that are not being displayed are added to the collection as null values until a call to the setWindow method causes them those items to be loaded.

This 'on-demand' method of loading data has advantages when dealing with large data sets, because it prevents the application from loading data until it is required. But it does impose some limitation: sorting and filtering must be done on the server; grouping and paging are not supported.

The example below uses an ODataVirtualCollectionView to load data from a NorthWind OData provider service. The collection loads data on-demant, as the user scrolls the grid:

{@sample Grid/Data-binding/VirtualOData/purejs Example}

Constructor

Properties

Methods

Events

Constructor

constructor

constructor(url: string, tableName: string, options?: any): ODataVirtualCollectionView

Initializes a new instance of the ODataVirtualCollectionView class.

Parameters
  • url: string

    Url of the OData service (for example https://services.odata.org/Northwind/Northwind.svc/ ).

  • tableName: string

    Name of the table (entity) to retrieve from the service. If not provided, a list of the tables (entities) available is retrieved.

  • options: any Optional

    JavaScript object containing initialization data (property values and event handlers) for the ODataVirtualCollectionView.

Returns
ODataVirtualCollectionView

Properties

calculatedFields

Gets or sets an object where the keys represent calculated fields and the values are expressions (functions or strings).

Calculated fields require proxies. To use them in IE11, you will need a polyfill such as this one: https://www.npmjs.com/package/proxy-polyfill.

Calculated fields can be useful when dealing with external data. For example, you could add a per-capita income field (gnp/pop) or a profit field (revenue-expenses).

Calculated fields are dynamic. If you change the fields used in the calculation, their values are updated automatically. They are also read-only. You may change the value of the properties used to calculate them, but you cannot directly edit the result.

Unlike FlexGrid cellTemplates, calculated fields can be used for sorting, filtering, and grouping. They can also be used with charts and any other Wijmo controls.

Calculated fields can be defined as functions that take a data item as an argument or as strings.

For example, if your data looked like this:

// regular data item
interface IDataItem {
      product: string,
      brand: string,
      unitPrice: number,
      qty: number,
      shipped: boolean
}
function getData(): IDataItem[] {
    return [
        { 
            product: 'Banana', 
            brand: 'Chiquita',
            unitPrice: 45.95,
            qty: 12,
            discount: .08,
            shipped: true
        }, ...
    ]
}

You could add function-based calculated fields this way:

// add calculated properties to IDataItem
interface ICalcDataItem extends IDataItem {
    fullName: string;
    allCaps: string;
    totalPrice: number,
    tax: number;
}



let cv = new CollectionView(getData(), { calculatedFields: { fullName: ($: ICalcDataItem) => [$.brand, $.product].join(' '), allCaps: ($: ICalcDataItem) => $.fullName.toUpperCase(), totalPrice: ($: ICalcDataItem) => ($.unitPrice * $.qty) * (1 - $.discount), tax: ($: ICalcDataItem) => $.totalPrice * 0.12 } });

**Function-based calculated fields** are usually a better choice than string-based calculated fields because:

1) They provide design-time error checking and command completion, 2) They run faster, and 3) They do not have any issues with content-security policy (CSP).

Alternatively, you could add string-based calculated fields:

let cv = new CollectionView(getData(), {
  calculatedFields: {
    fullName: '[$.brand, $.product].join(" ")',
    allCaps: '$.fullNameStr.toUpperCase()',
    totalPrice: '($.unitPrice * $.qty) * (1 - $.discount)',
    tax: '$.totalPrice * 0.12'
});

String expressions may refer to the current item via the context variable '$', which contains the item's original and calculated values.

**String-based calculated fields** have advantages over function-based calculated fields that may be important in some scenarios:

1) They are slightly more concise, and 2) They can be stored as data and easily changed at run-time.

Inherited From
CollectionView
Type
any

canAddNew

Gets a value that indicates whether a new item can be added to the collection.

Inherited From
CollectionView
Type
boolean

canCancelEdit

Gets a value that indicates whether the collection view can discard pending changes and restore the original values of an edited object.

Inherited From
CollectionView
Type
boolean

canChangePage

Gets a value that indicates whether the pageIndex value can change.

Inherited From
CollectionView
Type
boolean

canFilter

Gets a value that indicates whether this view supports filtering via the filter property.

This property does not affect the filters property, which are always applied.

Inherited From
CollectionView
Type
boolean

canGroup

ODataVirtualCollectionView requires canGroup to be set to false.

Type
boolean

canRemove

Gets a value that indicates whether items can be removed from the collection.

Inherited From
CollectionView
Type
boolean

canSort

Gets a value that indicates whether this view supports sorting via the sortDescriptions property.

Inherited From
CollectionView
Type
boolean

currentAddItem

Gets the item that is being added during the current add transaction.

Inherited From
CollectionView
Type

currentEditItem

Gets the item that is being edited during the current edit transaction.

Inherited From
CollectionView
Type
T

currentItem

Gets or sets the current item in the view.

Inherited From
CollectionView
Type

currentPosition

Gets the ordinal position of the current item in the view.

Inherited From
CollectionView
Type
number

dataTypes

Gets or sets a JavaScript object to be used as a map for coercing data types when loading the data.

The object keys represent the field names and the values are DataType values that indicate how the data should be coerced.

For example, the code below creates an ODataCollectionView and specifies that 'Freight' values, which are stored as strings in the database, should be converted into numbers; and that three date fields should be converted into dates:

import { ODataCollectionView } from '@mescius/wijmo.odata';
import { DataType } from '@mescius/wijmo';
const url = 'http://services.odata.org/V4/Northwind/Northwind.svc/';
const orders = new ODataCollectionView(url, 'Orders', {
  dataTypes: {
    Freight: DataType.Number 
    OrderDate: DataType.Date,
    RequiredDate: DataType.Date,
    ShippedDate: DataType.Date,
  }
});

This property is useful when the database contains data stored in formats that do not conform to common usage.

In most cases you don't have to provide information about the data types, because the inferDataTypes property handles the conversion of Date values automatically.

If you do provide explicit type information, the inferDataTypes property is not applied. Because of this, any data type information that is provided should be complete, including all fields of type Date.

Inherited From
ODataCollectionView
Type
any

deferCommits

Gets or sets a value that causes the ODataCollectionView to defer commits back to the database.

The default value for this property is **false**, which causes any changes to the data to be immediately committed to the database.

If you set this property to **true**, it will automatically set the trackChanges property to true. After this, any changes to the data (including edits, additions, and removals) will be tracked but not committed to the database until you call the commitChanges method to commit the changes, or the cancelChanges method to discard all pending changes.

For example:

import { ODataCollectionView } from '@mescius/wijmo.odata';



// create data source let url = 'https://services.odata.org/...'; let view = new ODataCollectionView(url, 'Categories', { keys: [ 'ID' ] });


// defer commits view.deferCommits = true;


// handle commit/cancel changes buttons let btnCommit = document.getElementById('btn-commit') as HTMLButtonElement, btnCancel = document.getElementById('btn-cancel') as HTMLButtonElement; btnCommit.addEventListener('click', () => view.commitChanges()); btnCancel.addEventListener('click', () => view.cancelChanges()); view.hasPendingChangesChanged.addHandler((s, e) => { btnCommit.disabled = btnCancel.disabled = !view.hasPendingChanges; });

Inherited From
ODataCollectionView
Type
boolean

entityType

Gets or sets a string that represents the entity's data type on the server.

This may be required to update data in some OData services.

For more details, please see http://docs.oasis-open.org/odata/odata-json-format/v4.0/cs01/odata-json-format-v4.0-cs01.html#_Toc365464687.

Inherited From
ODataCollectionView
Type
string

expand

Gets or sets a string that specifies whether related entities should be included in the return data.

This property maps directly to OData's $expand option.

For example, the code below retrieves all the customers and their orders from the database. Each customer entity has an "Orders" field that contains an array of order objects:

import { ODataCollectionView } from '@mescius/wijmo.odata';
const url = 'http://services.odata.org/V4/Northwind/Northwind.svc/';
const customersOrders = new ODataCollectionView(url, 'Customers', {
  expand: 'Orders'
});

Inherited From
ODataCollectionView
Type
string

fields

Gets or sets an array containing the names of the fields to retrieve from the data source.

If this property is set to null or to an empty array, all fields are retrieved.

For example, the code below creates an ODataCollectionView that gets only three fields from the 'Categories' table in the database:

import { ODataCollectionView } from '@mescius/wijmo.odata';
const url = 'http://services.odata.org/V4/Northwind/Northwind.svc/';
const categories = new ODataCollectionView(url, 'Categories', {
  fields: ['CategoryID', 'CategoryName', 'Description']
});

Inherited From
ODataCollectionView
Type
string[]

filter

Gets or sets a callback used to determine if an item is suitable for inclusion in the view.

The callback should return true if the item passed in as a parameter should be included in the view.

The default value for this property is **null**, which means the data is not filtered.

Inherited From
CollectionView
Type
IPredicate

filterDefinition

Gets or sets a string containing an OData filter specification to be used for filtering the data on the server.

The filter definition syntax is described in the OData documentation.

For example, the code below causes the server to return records where the 'CompanyName' field starts with 'A' and ends with 'S':

view.filterDefinition = "startswith(CompanyName, 'A') and endswith(CompanyName, 'B')";

Filter definitions can be generated automatically. For example, the FlexGridFilter component detects whether its data source is an ODataCollectionView and automatically updates both the filter and filterDefinition properties.

Note that the filterDefinition property is applied even if the filterOnServer property is set to false. This allows you to apply server and client filters to the same collection, which can be useful in many scenarios.

For example, the code below uses the filterDefinition property to filter on the server and the filter property to further filter on the client. The collection will show items with names that start with 'C' and have unit prices greater than 20:

import { ODataCollectionView } from '@mescius/wijmo.odata';
const url = 'http://services.odata.org/V4/Northwind/Northwind.svc/';
const data = new ODataCollectionView(url, 'Products', {
  oDataVersion: 4,
  filterDefinition: 'startswith(ProductName, \'C\')', // server filter
  filterOnServer: false, // client filter
  filter: function(product) { 
    return product.UnitPrice > 20;
  },
});

Inherited From
ODataCollectionView
Type
string

filterOnServer

ODataVirtualCollectionView requires filterOnServer to be set to true.

Type
boolean

filters

Gets an array of IPredicate functions used as filters on this CollectionView.

To be included in the view, an item has to pass the predicate in the filter property as well as all predicates in the filters collection.

Inherited From
CollectionView
Type
ObservableArray

getError

Gets or sets a callback that determines whether a specific property of an item contains validation errors.

The method takes as parameters a data item, the property being validated, and a parsing parameter that describes whether the data has already been parsed and applied to the data item (parsing == false), or whether the user was trying to edit the value and entered a value that could not be parsed into the data type expected (parsing == true).

The method returns a string containing an error message, or null if no errors were detected.

For example,

view = new CollectionView(data, {
    getError: (item: any, prop: string, parsing: boolean) => {



// parsing failed, show message if (parsing) { if (prop == 'date') { return 'Please enter a valid date in the format "MM/dd/yyyy"'; } else if (prop == 'id') { return 'Please enter a positive number'; } }


// check that stored (parsed) data is valid if (prop == 'date' && item.date < minDate) { return 'Please enter a date after ' + Globalize.formatDate(minDate, 'd'); } else if (prop == 'id' && item.id < 0) { return 'Please enter a positive number'; } } });

Inherited From
CollectionView
Type
IGetError

groupDescriptions

Gets a collection of GroupDescription objects that describe how the items in the collection are grouped in the view.

Inherited From
CollectionView
Type
ObservableArray

groups

Gets an array of CollectionViewGroup objects that represents the top-level groups.

Inherited From
CollectionView
Type
CollectionViewGroup[]

hasPendingChanges

Gets a value that determines whether the ODataCollectionView has pending changes.

See also the deferCommits property and the commitChanges and cancelChanges methods.

Inherited From
ODataCollectionView
Type
boolean

inferDataTypes

Gets or sets a value that determines whether fields that contain strings that look like standard date representations should be converted to dates automatically.

This property is set to true by default, because the ODataCollectionView class uses JSON and that format does not support Date objects.

This property has no effect if specific type information is provided using the dataTypes property.

Inherited From
ODataCollectionView
Type
boolean

isAddingNew

Gets a value that indicates whether an add transaction is in progress.

Inherited From
CollectionView
Type
boolean

isEditingItem

Gets a value that indicates whether an edit transaction is in progress.

Inherited From
CollectionView
Type
boolean

isEmpty

Gets a value that indicates whether this view contains no items.

Inherited From
CollectionView
Type
boolean

isLoading

Gets a value that indicates the ODataCollectionView is currently loading data.

This property can be used to provide progress indicators.

Inherited From
ODataCollectionView
Type
boolean

isPageChanging

Gets a value that indicates whether the page index is changing.

Inherited From
CollectionView
Type
boolean

isUpdating

Gets a value that indicates whether notifications are currently suspended (see beginUpdate and endUpdate).

Inherited From
CollectionView
Type

itemCount

Gets the total number of items in the view taking paging into account.

Inherited From
CollectionView
Type
number

items

Gets items in the view.

Inherited From
CollectionView
Type

itemsAdded

Gets an ObservableArray containing the records that were added to the collection since trackChanges was enabled.

Inherited From
CollectionView
Type
ObservableArray

itemsEdited

Gets an ObservableArray containing the records that were edited in the collection since trackChanges was enabled.

Inherited From
CollectionView
Type
ObservableArray

itemsRemoved

Gets an ObservableArray containing the records that were removed from the collection since trackChanges was enabled.

Inherited From
CollectionView
Type
ObservableArray

jsonReviver

Gets or sets a custom reviver function to use when parsing JSON values returned from the server.

If provided, the function must take two parameters (key and value), and must return the parsed value (which can be the same as the original value).

For details about reviver functions, please refer to the documentation for the JSON.parse method.

Inherited From
ODataCollectionView
Type
Function

keys

Gets or sets an array containing the names of the key fields.

Key fields are required for update operations (add/remove/delete).

Inherited From
ODataCollectionView
Type
string[]

newItemCreator

Gets or sets a function that creates new items for the collection.

If the creator function is not supplied, the CollectionView will try to create an uninitialized item of the appropriate type.

If the creator function is supplied, it should be a function that takes no parameters and returns an initialized object of the proper type for the collection.

Inherited From
CollectionView
Type
IItemCreator

oDataVersion

Gets or sets the OData version used by the server.

There are currently four versions of OData services, 1.0 through 4.0. Version 4.0 is used by the latest services, but there are many legacy services still in operation.

If you know what version of OData your service implements, set the oDataVersion property to the appropriate value (1 through 4) when creating the ODataCollectionView (see example below).

import { ODataCollectionView } from '@mescius/wijmo.odata';
let url = 'https://services.odata.org/Northwind/Northwind.svc/';
let categories = new ODataCollectionView(url, 'Categories', {
  oDataVersion: 1.0, // legacy OData source
  fields: ['CategoryID', 'CategoryName', 'Description'],
  sortOnServer: false
});

If you do not know what version of OData your service implements (perhaps you are writing an OData explorer application), then do not specify the version. In this case, the ODataCollectionView will get this information from the server. This operation requires an extra request, but only once per service URL, so the overhead is small.

Inherited From
ODataCollectionView
Type
number

pageCount

Gets the total number of pages.

Inherited From
ODataCollectionView
Type
number

pageIndex

Gets the zero-based index of the current page.

Inherited From
CollectionView
Type
number

pageOnServer

ODataVirtualCollectionView requires pageOnServer to be set to true.

Type
boolean

pageSize

Gets or sets the number of items to display on a page.

Inherited From
ODataCollectionView
Type
number

refreshOnEdit

Gets or sets a value that determines whether the CollectionView should automatically refresh its results (by applying the sort, filter, and grouping operations) after items are edited.

The default value for this property is **true**, which ensures the collection is always sorted, filtered, and grouped correctly after any edit operations.

Set it to **false** if you want updates to be deferred when items are edited. In this case, the collection will not be refreshed until the sorting, filtering, and grouping criteria change or until the refresh method is called (Excel behavior).

Inherited From
CollectionView
Type
boolean

requestCanceled

Occurs when the ODataVirtualCollectionView cancels a pending data request.

Type
Event

requestHeaders

Gets or sets an object containing request headers to be used when sending or requesting data.

The most typical use for this property is in scenarios where authentication is required. For example:

import { ODataCollectionView } from '@mescius/wijmo.odata';
const url = 'http://services.odata.org/V4/Northwind/Northwind.svc/';
const categories = new ODataCollectionView(serviceUrl, 'Categories', {
  fields: ['Category_ID', 'Category_Name'],
  requestHeaders: { Authorization: db.token }
});

Inherited From
ODataCollectionView
Type
any

showDatesAsGmt

Gets or sets a value that determines whether dates should be adjusted to look like GMT rather than local dates.

Inherited From
ODataCollectionView
Type

sortComparer

Gets or sets a function used to compare values when sorting.

If provided, the sort comparer function should take as parameters two values of any type, and should return -1, 0, or +1 to indicate whether the first value is smaller than, equal to, or greater than the second. If the sort comparer returns null, the standard built-in comparer is used.

This sortComparer property allows you to use custom comparison algorithms that in some cases result in sorting sequences that are more consistent with user's expectations than plain string comparisons.

For example, see Dave Koele's Alphanum algorithm. It breaks up strings into chunks composed of strings or numbers, then sorts number chunks in value order and string chunks in ASCII order. Dave calls the result a "natural sorting order".

The example below shows a typical use for the sortComparer property:

import { CollectionView, isString } from '@mescius/wijmo';



// create a CollectionView with a custom sort comparer const view = new CollectionView(data, { sortComparer: (a: any, b: any) => { return isString(a) && isString(b) ? alphanum(a, b) // use custom comparer for strings : null; // use default comparer for everything else } });

The example below shows how you can use an Intl.Collator to control the sort order:

import { CollectionView, isString } from '@mescius/wijmo';



// create a CollectionView that uses an Intl.Collator to sort const collator = window.Intl ? new Intl.Collator() : null; let view = new CollectionView(data, { sortComparer: (a, b) => { return isString(a) && isString(b) && collator ? collator.compare(a, b) // use collator for strings : null; // use default comparer for everything else } });

Inherited From
CollectionView
Type
IComparer

sortConverter

Gets or sets a function used to convert values when sorting.

If provided, the function should take as parameters a SortDescription, a data item, and a value to convert, and should return the converted value.

This property provides a way to customize sorting. For example, the FlexGrid control uses it to sort mapped columns by display value instead of by raw value.

For example, the code below causes a CollectionView to sort the 'country' property, which contains country code integers, using the corresponding country names:

const countries = 'US,Germany,UK,Japan,Italy,Greece'.split(',');
view.sortConverter = (sd: SortDescription, item: any, value: any) => {
    return sd.property === 'countryMapped'
        ? countries[value]; // convert country id into name
        : value;
}

The next example combines two values so when sorting by country, the view will break ties by city:

view.sortConverter: (sd: SortDescription, item: any, value: any) => {
    if (sd.property == 'country') {
        value = item.country + '\t' + item.city;
    }
    return value;
}

Inherited From
CollectionView
Type
ISortConverter

sortDescriptions

Gets an array of SortDescription objects that describe how the items in the collection are sorted in the view.

Inherited From
CollectionView
Type
ObservableArray

sortNulls

Gets or sets a value that determines how null values should be sorted.

This property is set to **SortNulls.Last** by default, which causes null values to appear last on the sorted collection, regardless of sort direction. This is also the default behavior in Excel.

Inherited From
CollectionView
Type
SortNulls

sortOnServer

ODataVirtualCollectionView requires sortOnServer to be set to true.

Type
boolean

sourceCollection

Gets or sets the underlying (unfiltered and unsorted) collection.

Inherited From
CollectionView
Type

tableName

Gets the name of the table (entity) that this collection is bound to.

Inherited From
ODataCollectionView
Type
string

totalItemCount

Gets the total number of items in the view before paging is applied.

Inherited From
ODataCollectionView
Type
number

trackChanges

Gets or sets a value that determines whether the control should track changes to the data.

The default value for this property is **false**, so the CollectionView does not keep track of which data items have changed.

If you set this property to **true**, the CollectionView will keep track of changes to the data and will expose them through the itemsAdded, itemsRemoved, and itemsEdited collections.

Tracking changes is useful in situations where you need to update the server after the user has confirmed that the modifications are valid.

After committing or cancelling changes, use the clearChanges method to clear the itemsAdded, itemsRemoved, and itemsEdited collections.

The CollectionView only tracks changes made when the proper CollectionView methods are used (editItem/commitEdit, addNew/commitNew, and remove). Changes made directly to the data are not tracked.

Inherited From
CollectionView
Type
boolean

useStableSort

Gets or sets whether to use a stable sort algorithm.

Stable sorting algorithms maintain the relative order of records with equal keys. For example, consider a collection of objects with an "Amount" field. If you sort the collection by "Amount", a stable sort will keep the original order of records with the same Amount value.

The default value for this property is **false**, which causes the CollectionView to use JavaScript's built-in sort method, which is fast and usually stable.

Chrome provides stable sorting since version 70, and Firefox since version 3. As of ES2019, sort is **required** to be stable. In ECMAScript 1st edition through ES2018, it was allowed to be unstable.

Setting the useStableSort property to true ensures stable sorts on all browsers (even IE 11), but increases sort times by 30% to 50%.

Inherited From
CollectionView
Type
boolean

Methods

addNew

addNew(item?: (Partial | T), commit): void

Adds a new item to the collection.

Calling this methods without any parameters creates a new item, adds it to the collection, and defers refresh operations until the new item is committed using the commitNew method or canceled using the cancelNew method.

The code below shows how the addNew method is typically used:

// create the new item, add it to the collection
var newItem = view.addNew();



// initialize the new item newItem.id = getFreshId(); newItem.name = 'New Customer';


// commit the new item so the view can be refreshed view.commitNew();

You can also add new items by pushing them into the sourceCollection and then calling the refresh method. The main advantage of addNew is in user-interactive scenarios (like adding new items in a data grid), because it gives users the ability to cancel the add operation. It also prevents the new item from being sorted or filtered out of view until the transaction is committed.

New items are empty objects by default, unless the colletion has calculatedFields, in which case the new items will have properties set to values that depend on their data types (empty strings for string properties, zero for numeric properties, and null for other data types).

This behavior is convenient since in many cases the calculated fields depend on expressions that rely on strings not being null. But you can customize this behavior by setting the newItemCreator property to a function that creates the new items and initializes them in any way you want.

Parameters
  • item: (Partial | T), commit Optional

    Item to be added to the collection (optional).

Inherited From
CollectionView
Returns
void

beginUpdate

beginUpdate(): void

Suspend refreshes until the next call to endUpdate.

Inherited From
CollectionView
Returns
void

cancelChanges

cancelChanges(): void

Cancels all changes by removing all items in the itemsAdded, itemsRemoved, and itemsEdited collections, without committing them to the server.

This method is used with the deferCommits property.

Inherited From
ODataCollectionView
Returns
void

cancelEdit

cancelEdit(): void

Ends the current edit transaction and, if possible, restores the original value to the item.

Inherited From
CollectionView
Returns
void

cancelNew

cancelNew(): void

Ends the current add transaction and discards the pending new item.

Inherited From
CollectionView
Returns
void

clearChanges

clearChanges(): void

Clears all changes by removing all items in the itemsAdded, itemsRemoved, and itemsEdited collections.

Call this method after committing changes to the server or after refreshing the data from the server.

Inherited From
CollectionView
Returns
void

commitChanges

commitChanges(committed?: (xhr: XMLHttpRequest)): void

Commits all pending changes to the server.

Changes are contained in the itemsEdited, itemsAdded, and itemsRemoved collections, and are automatically cleared after they are committed.

See also the deferCommits property.

Parameters
  • committed: (xhr: XMLHttpRequest) Optional

    Optional callback invoked when the commit operation has been completed. The callback takes an **XMLHttpRequest** parameter contains information about the request results.

Inherited From
ODataCollectionView
Returns
void

commitEdit

commitEdit(): void

Override commitEdit to modify the item in the database.

Inherited From
ODataCollectionView
Returns
void

commitNew

commitNew(): void

Override commitNew to add the new item to the database.

Inherited From
ODataCollectionView
Returns
void

contains

contains(item: T): boolean

Returns a value indicating whether a given item belongs to this view.

Parameters
  • item: T

    Item to seek.

Inherited From
CollectionView
Returns
boolean

deferUpdate

deferUpdate(fn: Function, force?: boolean): void

Executes a function within a beginUpdate/endUpdate block.

The collection will not be refreshed until the function finishes.

The deferUpdate method ensures endUpdate is called even if the update function throws an exception.

Parameters
  • fn: Function

    Function to be executed without updates.

  • force: boolean Optional

    Whether to force a refresh when ending the update.

Inherited From
CollectionView
Returns
void

editItem

editItem(item: T): void

Begins an edit transaction of the specified item.

Parameters
  • item: T

    Item to be edited.

Inherited From
CollectionView
Returns
void

endUpdate

endUpdate(force?: boolean): void

Resume refreshes suspended by a call to beginUpdate.

Parameters
  • force: boolean Optional

    Whether to force a refresh when ending the update.

Inherited From
CollectionView
Returns
void

getAggregate

getAggregate(aggType: Aggregate, binding: string, currentPage?: boolean): void

Calculates an aggregate value for the items in this collection.

Parameters
  • aggType: Aggregate

    Type of aggregate to calculate.

  • binding: string

    Property to aggregate on.

  • currentPage: boolean Optional

    Whether to include only items on the current page.

Inherited From
CollectionView
Returns
void

implementsInterface

implementsInterface(interfaceName: string): boolean

Returns true if this object supports a given interface.

Parameters
  • interfaceName: string

    Name of the interface to look for.

Inherited From
ODataCollectionView
Returns
boolean

load

load(): void

Loads or re-loads the data from the OData source.

Inherited From
ODataCollectionView
Returns
void

moveCurrentTo

moveCurrentTo(item: (Partial | T)): boolean

Sets the specified item to be the current item in the view.

Parameters
  • item: (Partial | T)

    Item that will become current.

Inherited From
CollectionView
Returns
boolean

moveCurrentToFirst

moveCurrentToFirst(): boolean

Sets the first item in the view as the current item.

Inherited From
CollectionView
Returns
boolean

moveCurrentToLast

moveCurrentToLast(): boolean

Sets the last item in the view as the current item.

Inherited From
CollectionView
Returns
boolean

moveCurrentToNext

moveCurrentToNext(): boolean

Sets the item after the current item in the view as the current item.

Inherited From
CollectionView
Returns
boolean

moveCurrentToPosition

moveCurrentToPosition(index: number): boolean

Sets the item at the specified index in the view as the current item.

Parameters
  • index: number

    Index of the item that will become current.

Inherited From
CollectionView
Returns
boolean

moveCurrentToPrevious

moveCurrentToPrevious(): boolean

Sets the item before the current item in the view as the current item.

Inherited From
CollectionView
Returns
boolean

moveToFirstPage

moveToFirstPage(): boolean

Sets the first page as the current page.

Inherited From
CollectionView
Returns
boolean

moveToLastPage

moveToLastPage(): boolean

Sets the last page as the current page.

Inherited From
CollectionView
Returns
boolean

moveToNextPage

moveToNextPage(): boolean

Moves to the page after the current page.

Inherited From
CollectionView
Returns
boolean

moveToPage

moveToPage(index: number): boolean

Moves to the page at the specified index.

Parameters
  • index: number

    Index of the page to move to.

Inherited From
CollectionView
Returns
boolean

moveToPreviousPage

moveToPreviousPage(): boolean

Moves to the page before the current page.

Inherited From
CollectionView
Returns
boolean

onCollectionChanged

onCollectionChanged(e?: NotifyCollectionChangedEventArgs, clone?: any): void

Raises the collectionChanged event.

Parameters
Inherited From
CollectionView
Returns
void

onCurrentChanged

onCurrentChanged(e?: EventArgs): void

Raises the currentChanged event.

Parameters
Inherited From
CollectionView
Returns
void

onCurrentChanging

onCurrentChanging(e: CancelEventArgs): boolean

Raises the currentChanging event.

Parameters
Inherited From
CollectionView
Returns
boolean

onError

onError(e: RequestErrorEventArgs): boolean

Raises the error event.

By default, errors throw exceptions and trigger a data refresh. If you want to prevent this behavior, set the cancel parameter to true in the event handler.

Parameters
Inherited From
ODataCollectionView
Returns
boolean

onHasPendingChangesChanged

onHasPendingChangesChanged(e?: EventArgs): void

Raises the hasPendingChangesChanged event.

Parameters
Inherited From
ODataCollectionView
Returns
void

onLoaded

onLoaded(e?: EventArgs): void

Raises the loaded event.

Parameters
Inherited From
ODataCollectionView
Returns
void

onLoading

onLoading(e?: EventArgs): void

Raises the loading event.

Parameters
Inherited From
ODataCollectionView
Returns
void

onPageChanged

onPageChanged(e?: EventArgs): void

Raises the pageChanged event.

Parameters
Inherited From
CollectionView
Returns
void

onPageChanging

onPageChanging(e: PageChangingEventArgs): boolean

Raises the pageChanging event.

Parameters
Inherited From
ODataCollectionView
Returns
boolean

onRequestCanceled

onRequestCanceled(e?: EventArgs): void

Raises the requestCanceled event.

Parameters
Returns
void

onSourceCollectionChanged

onSourceCollectionChanged(e?: EventArgs): void

Raises the sourceCollectionChanged event.

Parameters
Inherited From
CollectionView
Returns
void

onSourceCollectionChanging

onSourceCollectionChanging(e: CancelEventArgs): boolean

Raises the sourceCollectionChanging event.

Parameters
Inherited From
CollectionView
Returns
boolean

refresh

refresh(): void

Re-creates the view using the current sort, filter, and group parameters.

Inherited From
CollectionView
Returns
void

remove

remove(item: any): void

Override remove to remove the item from the database.

Parameters
  • item: any

    Item to be removed from the database.

Inherited From
ODataCollectionView
Returns
void

removeAt

removeAt(index: number): void

Removes the item at the specified index from the collection.

Parameters
  • index: number

    Index of the item to be removed from the collection. The index is relative to the view, not to the source collection.

Inherited From
CollectionView
Returns
void

setWindow

setWindow(start: number, end: number): void

Sets the data window to ensure a range of records are loaded into the view.

Parameters
  • start: number

    Index of the first item in the data window.

  • end: number

    Index of the last item in the data window.

Returns
void

updateFilterDefinition

updateFilterDefinition(filterProvider: any): void

Updates the filter definition based on a known filter provider such as the FlexGridFilter.

Parameters
  • filterProvider: any

    Known filter provider, typically an instance of a FlexGridFilter.

Inherited From
ODataCollectionView
Returns
void

Events

collectionChanged

Occurs when the collection changes.

Inherited From
CollectionView
Arguments
EventArgs

currentChanged

Occurs after the current item changes.

Inherited From
CollectionView
Arguments
EventArgs

currentChanging

Occurs before the current item changes.

Inherited From
CollectionView
Arguments
CancelEventArgs

error

Occurs when there is an error reading or writing data.

Inherited From
ODataCollectionView
Arguments
RequestErrorEventArgs

hasPendingChangesChanged

Occurs when the value of the hasPendingChanges property changes.

See also the deferCommits property.

Inherited From
ODataCollectionView
Arguments
EventArgs

loaded

Occurs when the ODataCollectionView finishes loading data.

Inherited From
ODataCollectionView
Arguments
EventArgs

loading

Occurs when the ODataCollectionView starts loading data.

Inherited From
ODataCollectionView
Arguments
EventArgs

pageChanged

Occurs after the page index changes.

Inherited From
CollectionView
Arguments
EventArgs

pageChanging

Occurs before the page index changes.

Inherited From
CollectionView
Arguments
PageChangingEventArgs

sourceCollectionChanged

Occurs after the value of the sourceCollection property changes.

Inherited From
CollectionView
Arguments
EventArgs

sourceCollectionChanging

Occurs before the value of the sourceCollection property changes.

Inherited From
CollectionView
Arguments
CancelEventArgs