43
Name
Type
Description
pageIndex
number
Gets the zero-based index of the current page.
(inherited from CollectionView).
pageSize
number
Gets or sets the number of items to display on a page.
(inherited from CollectionView).
sortConverter
Function
Gets or sets a function used to convert values when sorting.
If provided, the function should take as parameters a SortDescription, a data
ata
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
of
by raw value.
For example, the code below causes a CollectionView to sort the 'country'
try'
property, which contains country code integers, using the corresponding
country names:
var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(',');
collectionView.sortConverter = function (sd, item, value) {
if (sd.property == 'countryMapped') {
value = countries[value]; // convert country id into name
}
return value;
}
(inherited from CollectionView).
.
sortDescriptions
ObservableArray
Gets a collection of SortDescription objects that describe how the items in the
collection are sorted in the view.
(inherited from CollectionView).
sourceCollection
any
Gets or sets the underlying (unfiltered and unsorted) collection.
(inherited from CollectionView).
43
Name
Type
Description
totalItemCount
number
Gets the total number of items in the view before paging is applied.
(inherited from CollectionView).
trackChanges
boolean
Gets or sets a value that determines whether the control should track changes to
the data.
If trackChanges is set to true, the CollectionView keeps track of changes to
anges to
the data and exposes 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
ear
the itemsAdded , itemsRemoved , and itemsEdited collections.
ions.
The CollectionView only tracks changes made when the
he
proper CollectionView methods are used
ed
(editItem /commitEdit,addNew /commitNew , and remove). Changes made
anges made
directly to the data are not tracked.
(inherited from CollectionView).
.
useStableSort
boolean
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.
This property is false by default, which causes the CollectionView to use
use
JavaScript's built-in sort method, which is very fast but not stable.
e.
38
Name
Type
Description
Setting stableSort to true increases sort times by 30% to 50%, which can be
be
significant for large collections.
(inherited from CollectionView).
.
Methods
Name
Parameters
Description
addNew(): any
Creates a new item and adds it to the
collection.
This method takes no parameters. It
creates a new item, adds it to the
collection, and prevents refresh
operations until the new item is
committed using
the commitNew method or canceled
ed
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
38
Name
Parameters
Description
the sourceCollection and then calling
ling
therefresh method. The main
n
advantage of addNew is in user-
r-
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 add operation is
committed.
Returns The item that was added to
the collection.
(inherited from CollectionView ).
.
beginUpdate()
Suspend refreshes until the next call
to endUpdate.
(inherited from CollectionView).
cancelEdit()
Ends the current edit transaction and,
if possible, restores the original value
to the item.
(inherited from CollectionView).
cancelNew()
Ends the current add transaction and
discards the pending new item.
(inherited from CollectionView).
clearChanges()
Clears all changes by removing all
items in
the itemsAdded , itemsRemoved ,
and itemsEdited collections.
42
Name
Parameters
Description
Call this method after committing
changes to the server or after
refreshing the data from the server.
(inherited from CollectionView).
.
commitEdit()
Ends the current edit transaction and
saves the pending changes.
(inherited from CollectionView).
commitNew()
Ends the current add transaction and
saves the pending new item.
(inherited from CollectionView).
contains(item): boolean
item (any): Item to seek.
Returns a value indicating whether a
given item belongs to this view.
(inherited from CollectionView).
deferUpdate(fn)
fn (Function): Function to be executed without updates.
Executes a function within
a beginUpdate/endUpdate block.
k.
The collection will not be refreshed
until the function finishes. This
method ensures endUpdate is called
ed
even if the function throws.
(inherited from CollectionView).
).
editItem(item)
item (any): Item to be edited.
Begins an edit transaction of the
specified item.
(inherited from CollectionView).
endUpdate()
Resume refreshes suspended by a call
to beginUpdate.
(inherited from CollectionView).
47
Name
Parameters
Description
implementsInterface
(interfaceName):boolean
interfaceName (string): Name of the interface to look for. Returns true if the caller queries for a
supported interface.
(inherited from CollectionView).
moveCurrentTo
(item): boolean
item (any): Item that will become current.
Sets the specified item to be the
current item in the view.
(inherited from CollectionView).
moveCurrentToFirst
(): boolean
Sets the first item in the view as the
current item.
(inherited from CollectionView ).
moveCurrentToLast
(): boolean
Sets the last item in the view as the
current item.
(inherited from CollectionView).
moveCurrentToNext
(): boolean
Sets the item after the current item in
the view as the current item.
(inherited from CollectionView).
moveCurrentToPosition
(index):boolean
index (number): Index of the item that will become current. Sets the item at the specified index in
the view as the current item.
(inherited from CollectionView).
moveCurrentToPrevious
(): boolean
Sets the item before the current item
in the view as the current item.
(inherited from CollectionView).
moveToFirstPage(): boolean
Sets the first page as the current page.
Returns True if the page index was
changed successfully.
(inherited from CollectionView).
moveToLastPage(): boolean
Sets the last page as the current page.
Returns True if the page index was
49
Name
Parameters
Description
changed successfully.
(inherited from CollectionView).
moveToNextPage(): boolean
Moves to the page after the current
page.
Returns True if the page index was
changed successfully.
(inherited from CollectionView).
moveToPage(index): boolean index (number): Index of the page to move to.
Moves to the page at the specified
index.
Returns True if the page index was
changed successfully.
(inherited from CollectionView).
moveToPreviousPage
(): boolean
Moves to the page before the current
page.
Returns True if the page index was
changed successfully.
(inherited from CollectionView ).
onCollectionChanged(e?)
e? (): Contains a description of the change.
(default value: NotifyCollectionChangedEventArgs.reset)
Raises the collectionChanged event.
(inherited from CollectionView).
onCurrentChanged(e?)
e? ()
(default value: EventArgs.empty)
Raises the currentChanged event.
(inherited from CollectionView).
onCurrentChanging
(e): boolean
e (CancelEventArgs): CancelEventArgs that contains the
event data.
Raises the currentChanging event.
(inherited from CollectionView).
onPageChanged(e?)
e? ()
(default value: EventArgs.empty)
Raises the pageChanged event.
(inherited from CollectionView).
onPageChanging(e): boolean e (PageChangingEventArgs): PageChangingEventArgs tha
t contains the event data.
Raises the pageChanging event.
(inherited from CollectionView ).
Documents you may be interested
Documents you may be interested