RecordSet.getItemID( )


RecordSet.getItemID( ) Method Flash 6

retrieves the internal ID number of a row
   myRecordSet   .getItemID(   index   ) 

Arguments

index

An integer between 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) == 0) {     trace(myRecordset_rs.getItemID(i));     break;   } } 

After the recordset is sorted, the first record is " Biff Bop ", but its item ID is still 2 . The second record in the sorted recordset is " Tom Muck ", but its item ID is , telling us that it was the original first record. The trace( ) statement displays Tom's record in the Output window.

See Also

RecordSet.addItemAt( ) , RecordSet.sortItemsBy( ) ; Chapter 3 and Chapter 4



Flash Remoting
Flash Remoting: The Definitive Guide
ISBN: 059600401X
EAN: 2147483647
Year: 2003
Pages: 239
Authors: Tom Muck

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net