Name

RecordSet.getItemID( ) Method

Synopsis

                     myRecordSet.getItemID(index)

Arguments

index

An integer between 0 and the length of the RecordSet object minus one.

Returns

The internal ID number that Flash assigns when the record is added to the recordset.

Description

The getItemID( ) method returns an internal ID and is useful for determining the initial state of the RecordSet object (or the order in which records were added). If the order of the records in the recordset changes in some way, it can be restored or compared by using the original identifier that was given to each row when the recordset was created. Unlike the index of a record, which can change, the internal ID never changes and is destroyed if the row is deleted. The identifier of a deleted row is not reused again.

Example

The following code retrieves the original first row from the recordset, even after the sort changes the order of the rows:

#include "RecordSet.as" var myRecordset_rs = new RecordSet(["First","Last","Email"]); myRecordset_rs.addItem({First:"Tom", Last:"Muck", Email:"tom@tom-muck.com"}); myRecordset_rs.addItem({First:"Jack", Last:"Splat", Email:"jack@tom-muck.com"}); myRecordset_rs.addItem({First:"Biff", Last:"Bop", Email:"biff@tom-muck.com"}); // "Tom Muck" is the first item before the sort. After the sort, it is second. myRecordset_rs.sortItemsBy("Last"); // Loop through the records looking for the one whose original ID is 0 for (var i; i < myRecordset_rs.getLength( ); i++) { if (myRecordset_rs.getItemID(i) ...

Get Flash Remoting: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.