Name
RecordSet.addItemAt( ) Method
Synopsis
myRecordSet
.addItemAt(index
,record
)
Arguments
-
index
An integer from
0
to the length of the recordset minus one.-
record
An object with properties that match the fields of the existing RecordSet object.
Description
The addItemAt( ) method inserts a record at a specified location by passing an index number to the recordset along with the record being inserted. It differs from addItem( ) in that the record need not be appended to the end of the recordset but rather can be inserted at any valid index.
Example
The following code creates a RecordSet object, adds two rows using the addItem( ) method, then adds another row using addItemAt( ):
#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.addItemAt(0,{First:"Biff", Last:"Bop", Email:"biff@tom-muck.com"});
At this point, the first record (at index 0
) is
the last one that was added, because the addItemAt(
) method was used to insert the record at the
0
position within the recordset. However, the
internal identifier of this record is 2
because it
was added third:
trace(myRecordset_rs.getItemId(0)); // Returns 2
See Also
RecordSet.addItem( ); Chapter 4
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.