2003 Macromedia, Inc. 17
9. Use the FGridColumn(colname) constructor to create a new datagrid
column. The argument must match the name of the object property
that you want to display in this column (case is not important). For
example, if you want the name property to appear, use Name as the
argument:
name_col = new FGridColumn("Name");
10. The string Name will appear in the header by default. If you want
something different, use the setHeader() method to specify a different
header for this column:
name_col.setHeader("Product Name");
11. Set the width of this column. Use the width of the DataGrid as a guide
to the number of pixels a certain column may use. Start with 150
pixels for the name:
name_col.setWidth(150);
12. Finally, add the name_col column to the datagrid:
product_dg.addColumn(name_col);
13. Create new columns for the description and price properties, using 550
and 80 as the respective widths.
14. The finished code could look like this:
name_col = new FGridColumn("Name");
name_col.setHeader("Product Name");
name_col.setWidth(150);
product_dg.addColumn(name_col);
desc_col = new FGridColumn("Description");
desc_col.setWidth(550);
product_dg.addColumn(desc_col);
price_col = new FGridColumn("Price");
price_col.setWidth(80);
product_dg.addColumn(price_col);
15. Test the movie. Click the headers to sort the data. Resize the columns
by dragging the vertical bars between the headers.
16. Publish this document as Flash and HTML.
17. Edit the html to include other text you want to display on the page in
addition to the flash documents.
Conclusion
With the DataGrid you have a powerful component that allows you to
display large amounts of data, format it and even edit it. Macromedia is
working hard to release additional new components that use APIs similar
to the one you used for the DataGrid. Now that you are familiar with how
the APIs work with .NET, you are on your way to using Macromedia Flash
and Flash Remoting MX to create the next generation of applications for
the web.
Kommentare zu diesen Handbüchern