DataGlue.bindFormatStrings( )


DataGlue.bindFormatStrings( ) Method Flash 6

binds a data provider to a data consumer using string replacements
 DataGlue.bindFormatStrings(   dataConsumer   ,   dataProvider   ,   labelString   ,   dataString   ) 

Arguments

dataConsumer

The field that you want to sort the RecordSet object by.

dataProvider

The direction to sort the recordset. " DESC " specifies a descending sort; anything else is ascending .

labelString

The label that will show in the UI component.

dataString

The data that will correspond to the label in the UI component.

Description

The DataGlue object contains two methods for binding data to a UI component. The bindFormatFunction( ) method is best used when the data coming from the recordset or other data provider has to be formatted in a particular way. If the data can be used directly, the bindFormatStrings( ) method is easier to use because you don't have to define a custom function that formats the data. Simply specify the fields to use for the label and data properties of the data consumer in the method call.

Example

The following example code assumes a combo box named allProducts_cb is present on the main timeline:

 #include "NetServices.as" #include "DataGlue.as" // Initialize the connection and service objects. if (connected == null) {   connected = true;   NetServices.setDefaultGatewayUrl("http://localhost/flashservices/gateway");   var my_conn = NetServices.createGatewayConnection( );   var myService = my_conn.getService("com.oreilly.frdg.searchProducts", this); } // The remote   getSearchResult( )   method (not shown) returns a recordset. myService.getSearchResult( ); // Display the product names in the combo box. Use the product IDs as the data. function getSearchResult_Result(result_rs) {   DataGlue.bindFormatStrings(allProducts_cb, result_rs,      '#ProductName#', '#ProductID#'); } 

The fields that are utilized in the bindFormatStrings( ) method ( ProductName and ProductID ) are surrounded by quotes and pound signs ( # ). The pound signs around the RecordSet fields denote that the field is to be replaced by a field from the data provider (the RecordSet , in this case).

See Also

DataGlue.bindFormatFunction( ) , the RecordSet class; 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