Enhancing the RecordSet Class for Interactivity

Chapter 3 showed an enhancement to the RecordSet class that facilitated a user interface showing only one record at a time—a common way of displaying resultset data to the end user. The enhancement added the concept of a current record and provided methods to move to specific records (first, previous, next, last, and record number). To augment this functionality, let’s implement a feature to associate a field in a recordset with user interface controls and other elements (DataGlue style).

The Current Record Functionality

The current record functionality was described in Chapter 3, but we’ll add a few new methods to implement the gluing of components to individual RecordSet fields. The basic functionality that we will begin with is shown in Example 11-7.

Example 11-7. Adding current record functionality to a RecordSet
// Initialize the current record number RecordSet.prototype.currentRecord = 0; // Return the current record RecordSet.prototype.getCurrentRecord = function ( ) { return this.getItemAt(this.currentRecord-1); }; // Return the current record number RecordSet.prototype.getCurrentRecordNum = function ( ) { return this.currentRecord }; RecordSet.prototype.move = function (direction) { switch (direction.toLowerCase( )) { case "first": this.currentRecord = 1; break; case "previous": if (--this.currentRecord < 1) this.currentRecord = 1; break; case "next": if (++this.currentRecord > this.getLength( )) this.currentRecord = this.getLength( ...

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.