21.6. Using Recordsets with DataGrids
Problem
You want to display recordset data in a grid.
Solution
Use the DataGrid component.
Discussion
The DataGrid component is available for purchase from Macromedia as part of the
DevNet Resource Kit (DRK) Volume 1, available from http://www.macromedia.com/software/drk/productinfo/product_overview/volume1.
It is invaluable for displaying complex data sets such as recordsets.
Normal menus, such as list boxes, work great for showing
one-dimensional lists of values, but when it comes to displaying
two-dimensional (row and column) data, they are not up to par. The
DataGrid component allows you to display data as rows and columns,
and with the DataGrid.setDataProvider( ) method
or the DataGlue class, you can populate a data
grid with recordset data in short order.
The setDataProvider( ) method populates the
data
grid with data from a recordset. If the data grid has no defined
columns, columns that match the columns of the recordset in name and
order are automatically created.
#include "NetServices.as" // Create a new recordset with columns ID, FIRST, LAST. rs = new RecordSet(["ID", "FIRST", "LAST"]); rs.addItem({ID: 24, FIRST: "Bob", LAST: "Bobson"}); rs.addItem({ID: 42, FIRST: "Sarah", LAST: "Littlefoot"}); rs.addItem({ID: 66, FIRST: "George", LAST: "Georgeman"}); // Set the data grid to alternate row colors between white and light blue. myDataGrid.alternateRowColors(0xFFFFFF, 0xC1E0FD); // Populate the data grid with the recordset data. It creates ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access