getCurrentItemIndex( )


Returns the current item's index.

The getCurrentItemIndex() function returns the index of current item within the items of the dataset. The indices of the items in a dataset are zero-based. For example, if the third item is the current item, then getCurrentItemIndex() returns 2.

Calling getCurrentItemIndex() on a write-only dataset causes an error.

Returns null if one of the following is true if the dataset:

  • Is filtered to not match any items in the collection.
  • Is empty.
  • Has not loaded yet.

Note:

A dataset needs to load its data before you call its getCurrentItemIndex() function. Usually a dataset finishes loading a short time after the page it is on finishes loading. So if you call getCurrentItemIndex() inside the page’s onReady() event handler, the dataset might not be ready yet.

To call getCurrentItemIndex() as soon as possible after a page loads, use the dataset's onReady() function inside the page’s onReady() event handler to ensure that both the page and the dataset have finished loading.

If the current item is changed from a non-dataset source, such as by selecting a row in a table connected to a dataset or clicking a button set to advance to the next item in a dataset, the dataset's current item is not updated immediately. Therefore, to get the dataset's new current item index, call getCurrentItemIndex() in the dataset's onCurrentIndexChanged() event handler. Do not use the events of the non-dataset source, such as onRowSelect or onClick, to call getCurrentItemIndex() because they will fire before the dataset's current item is updated.

Method Declaration
Copy
Request
This method does not take any parameters
Returns
Return Type:number
Was this helpful?
Yes
No