RE: [flexcoders] Adding rows to a datagrid programmatically

2005-12-05 Thread Theodore E Patrick
Title: Re: [flexcoders] Adding rows to a datagrid programmatically










Correction:

 

myDP = new flow.DataProvider()

myDatagrid.dataProvider = myDT

myDP.addItem( { name:’Ted’, age:33 } )

myDP.addItem( { name:’Fred’, age:20 } )

myDP.addItem( { name:’Jean’, age:25 } )

// set the filter such that only records
where age is less than 30 show

myDP.filter = “age<30”

 

Ted :)

 

 











From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Theodore E Patrick
Sent: Monday, December 05, 2005
12:18 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Adding
rows to a datagrid programmatically



 

Ralf,

 

The DataGrid maps column data to a
dataProvider via the ‘columnName’ property. You can also employ cellRenderers
and labelFunctions to render MovieClips/components and alternate text into the
Datagrid from the dataProvider value.

 

Here is an example dataGrid (Actually this
is the DataGrid used within the Flash By Example UI):

 



 

  

   

   

   

   

   

    

  

 



 

 

I could do the following with this
Datadrig instance:

 

//create a dataProvider >> The DataProvider
API decorates the base Array.prototype at runtime

 

myData = []

datagrid.dataProvider = myData

 

myData.addItem ( { icon:’i32’ , license:23
, n:’My Example 1’ , p:8 , f:8 } ) 

myData.addItem ( { icon:’i32’ , license:23
, n:’My Example 2’ , p:8 , f:8 } )

myData.addItem ( { icon:’i32’ , license:23
, n:’My Example 3’ , p:8 , f:8 } )

 

Using the addItem method within the
DataProvider API broadcasts change events to the datagrid view causing it to
update. You could also do this as they are identical:

 

datagrid.addItem ( { icon:’i32’ ,
license:23 , n:’My Example 1’ , p:8 , f:8 } ) 

datagrid.addItem ( { icon:’i32’ ,
license:23 , n:’My Example 2’ , p:8 , f:8 } )

datagrid.addItem ( { icon:’i32’ ,
license:23 , n:’My Example 3’ , p:8 , f:8 } )

 

When the datagrid renders rows, it uses
the cellRenderer to layout the cell column and used labelFunction to obtain the
cell text value. Once you see this working, you can do great things with the
DataGrid in terms of dynamically created values and inserting controls into the
datagrid.

 

The important thing to realize is that the
DataGrid used the dataProvider API from within the component but it is also
usable from the Array itself. If you happen to have 2 datagrids using the same
dataProvider reference, both will update when data is added using the
dataprovider API. If you add data using the base Array methods, you will not
see data update within the view until the datagrid row is visually refreshed.
If you rollover a datagrid row, all the data in the row will update from the
dataProvider.

 

This same model applies to all uses of the
dataProvider model. If you are using Trees, Lists, ComboBox, DataGrid,
Accordion, and many others, the dataProviders work essentially the same. Each
control interprets dataProvider contents slightly differently according to its
own features set. 

 

Just remember: Array == DataProvider via
decoration!

 

Here is the methods of the DataProvider
API that are added into the Array.prototype object at runtime.

 

dispatchQueue

dispatchEvent

removeEventListener

addEventListener

editField

getEditingData

removeItemsAt

addItemsAt

updateViews

sortItems

sortItemsBy

getItemID

getItemAt

replaceItemAt

removeItemAt

removeAll

addItemAt

addItem

addView

 

What is really nice is that you can write
a true DataProvider class by implementing this interface. On a prior Flex
project we wrote a filtered DataProvider that allows you to hide certain
records within a dataProvider by setting a filter value like so:

 

myDP = new flow.DataProvider()

myDatagrid.dataProvider = myDT

myDP.addItem( { name:’Ted’, age=33 } )

myDP.addItem( { name:’Fred’, age=20 } )

myDP.addItem( { name:’Jean’, age=25 } )

// set the filter such that only records
where age is less than 30 show

myDP.filter = “age<30”

 

Later in the app if you wanted to show all
rows simply say:

 

myDP.filter = undefined

 

Hopefully this more than covers your
initial question. Sorry for the rambling post.

 

Cheers,

 

Ted ;)

 

 

 

 

 

 











From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Ralf Rottmann
Sent: Monday, December 05, 2005
9:57 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Adding
rows to a datagrid programmatically



 

Thanks Ted.
I have created an Array of Objects which I assign to the dataProvider property
of my DataGrid. If I have manually added Columns with names and headerTexts, do
the Obj properties have to match ColumnNames, or does Flex kind of
"guess" which property should be assigned to which column?

Regards
RR
--
mobile: +49-(0)170-914-5495
email:   [EMAIL PROTECTED]




-Original Message-
From: flexcoders@yahoogroups.com
<flexcoders@yahoogroups.com>
To: flexcoders@yahoogroups.com <flexcoders@yahoogroups

RE: [flexcoders] Adding rows to a datagrid programmatically

2005-12-05 Thread Theodore E Patrick
Title: Re: [flexcoders] Adding rows to a datagrid programmatically










Ralf,

 

The DataGrid maps column data to a
dataProvider via the ‘columnName’ property. You can also employ
cellRenderers and labelFunctions to render MovieClips/components and alternate
text into the Datagrid from the dataProvider value.

 

Here is an example dataGrid (Actually this
is the DataGrid used within the Flash By Example UI):

 



 

  

   

   

   

   

   

    

  

 



 

 

I could do the following with this
Datadrig instance:

 

//create a dataProvider >> The
DataProvider API decorates the base Array.prototype at runtime

 

myData = []

datagrid.dataProvider = myData

 

myData.addItem ( { icon:’i32’
, license:23 , n:’My Example 1’ , p:8 , f:8 } ) 

myData.addItem ( { icon:’i32’
, license:23 , n:’My Example 2’ , p:8 , f:8 } )

myData.addItem ( { icon:’i32’
, license:23 , n:’My Example 3’ , p:8 , f:8 } )

 

Using the addItem method within the
DataProvider API broadcasts change events to the datagrid view causing it to
update. You could also do this as they are identical:

 

datagrid.addItem ( { icon:’i32’
, license:23 , n:’My Example 1’ , p:8 , f:8 } ) 

datagrid.addItem ( { icon:’i32’
, license:23 , n:’My Example 2’ , p:8 , f:8 } )

datagrid.addItem ( { icon:’i32’
, license:23 , n:’My Example 3’ , p:8 , f:8 } )

 

When the datagrid renders rows, it uses
the cellRenderer to layout the cell column and used labelFunction to obtain the
cell text value. Once you see this working, you can do great things with the
DataGrid in terms of dynamically created values and inserting controls into the
datagrid.

 

The important thing to realize is that the
DataGrid used the dataProvider API from within the component but it is also
usable from the Array itself. If you happen to have 2 datagrids using the same
dataProvider reference, both will update when data is added using the
dataprovider API. If you add data using the base Array methods, you will not
see data update within the view until the datagrid row is visually refreshed.
If you rollover a datagrid row, all the data in the row will update from the
dataProvider.

 

This same model applies to all uses of the
dataProvider model. If you are using Trees, Lists, ComboBox, DataGrid,
Accordion, and many others, the dataProviders work essentially the same. Each
control interprets dataProvider contents slightly differently according to its
own features set. 

 

Just remember: Array == DataProvider via decoration!

 

Here is the methods of the DataProvider API
that are added into the Array.prototype object at runtime.

 

dispatchQueue

dispatchEvent

removeEventListener

addEventListener

editField

getEditingData

removeItemsAt

addItemsAt

updateViews

sortItems

sortItemsBy

getItemID

getItemAt

replaceItemAt

removeItemAt

removeAll

addItemAt

addItem

addView

 

What is really nice is that you can write
a true DataProvider class by implementing this interface. On a prior Flex
project we wrote a filtered DataProvider that allows you to hide certain
records within a dataProvider by setting a filter value like so:

 

myDP = new flow.DataProvider()

myDatagrid.dataProvider = myDT

myDP.addItem( { name:’Ted’,
age=33 } )

myDP.addItem( { name:’Fred’,
age=20 } )

myDP.addItem( { name:’Jean’,
age=25 } )

// set the filter such that only records
where age is less than 30 show

myDP.filter = “age<30”

 

Later in the app if you wanted to show all
rows simply say:

 

myDP.filter = undefined

 

Hopefully this more than covers your initial
question. Sorry for the rambling post.

 

Cheers,

 

Ted ;)

 

 

 

 

 

 











From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Ralf Rottmann
Sent: Monday, December 05, 2005
9:57 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Adding
rows to a datagrid programmatically



 

Thanks Ted.
I have created an Array of Objects which I assign to the dataProvider property
of my DataGrid. If I have manually added Columns with names and headerTexts, do
the Obj properties have to match ColumnNames, or does Flex kind of
"guess" which property should be assigned to which column?

Regards
RR
--
mobile: +49-(0)170-914-5495
email:   [EMAIL PROTECTED]




-Original Message-
From: flexcoders@yahoogroups.com
<flexcoders@yahoogroups.com>
To: flexcoders@yahoogroups.com <flexcoders@yahoogroups.com>
Sent: Mon Dec 05 05:55:46 2005
Subject: RE: [flexcoders] Adding rows to a datagrid programmatically

Ralf,



If you are trying to add a row to a DataGrid you use the DataProviderAPI like
so:



myDataGrid.addItem( { a:”Hello” , b:2 } )



cheers,



Ted ;)





From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com]
On Behalf Of Ralf Rottmann
Sent: Monday, December 05, 2005 12:29 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Adding rows to a datagrid programmatically



I looked for tutorials on the labs s

Re: [flexcoders] Adding rows to a datagrid programmatically

2005-12-05 Thread Ralf Rottmann
Title: Re: [flexcoders] Adding rows to a datagrid programmatically








Thanks Ted.
I have created an Array of Objects which I assign to the dataProvider property of my DataGrid. If I have manually added Columns with names and headerTexts, do the Obj properties have to match ColumnNames, or does Flex kind of "guess" which property should be assigned to which column?

Regards
RR
--
mobile: +49-(0)170-914-5495
email:   [EMAIL PROTECTED]




-Original Message-
From: flexcoders@yahoogroups.com 
To: flexcoders@yahoogroups.com 
Sent: Mon Dec 05 05:55:46 2005
Subject: RE: [flexcoders] Adding rows to a datagrid programmatically

Ralf,



If you are trying to add a row to a DataGrid you use the DataProviderAPI like so:



myDataGrid.addItem( { a:”Hello” , b:2 } )



cheers,



Ted ;)





From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Ralf Rottmann
Sent: Monday, December 05, 2005 12:29 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Adding rows to a datagrid programmatically



I looked for tutorials on the labs site but could not find any. Can somebody send a code example of how to add a row to a datagrid programmatically?



Best regards

Ralf






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development      Computer software development      Software design and development     
Macromedia flex <http://groups.yahoo.com/gads?t=ms&k=Macromedia+flex&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=OO6nPIrz7_EpZI36cYzBjw>     Software development best practice   



YAHOO! GROUPS LINKS


    *    Visit your group "flexcoders <http://groups.yahoo.com/group/flexcoders> " on the web.
     
*    To unsubscribe from this group, send an email to:
 [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
     
*    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> .





--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.11/191 - Release Date: 12/2/2005



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.11/191 - Release Date: 12/2/2005











--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





  




  
  
  YAHOO! GROUPS LINKS



   Visit your group "flexcoders" on the web. 
   To unsubscribe from this group, send an email to: [EMAIL PROTECTED] 
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  









RE: [flexcoders] Adding rows to a datagrid programmatically

2005-12-04 Thread Theodore E Patrick










Ralf,

 

If you are trying to add a row to a
DataGrid you use the DataProviderAPI like so:

 

myDataGrid.addItem( { a:”Hello” , b:2 } )

 

cheers,

 

Ted ;)

 











From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Ralf Rottmann
Sent: Monday, December 05, 2005
12:29 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Adding rows
to a datagrid programmatically



 

I looked for tutorials on the labs site but could not find
any. Can somebody send a code example of how to add a row to a datagrid
programmatically?

 

Best regards

Ralf

 









--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



   Visit your group "flexcoders" on the web. 
   To unsubscribe from this group, send an email to: [EMAIL PROTECTED] 
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  











--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.11/191 - Release Date: 12/2/2005
 

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.11/191 - Release Date: 12/2/2005
 


Re: [flexcoders] Adding rows to a datagrid programmatically

2005-12-04 Thread JesterXL





:: pseudo code ::
:: rave rave rave ::
 
import 
mx.controls.gridclasses.DataGridColumn;
var dgc:DataGridColum = new 
DataGridColumn("fieldName");
dgc.columnName = "fieldName";
dgc.headerText = "Pretty Field Name";
myDataGrid.addColumn(dgc);
 
 
- Original Message - 
From: Ralf 
Rottmann 
To: flexcoders@yahoogroups.com 
Sent: Sunday, December 04, 2005 5:29 PM
Subject: [flexcoders] Adding rows to a datagrid 
programmatically


I looked for tutorials on the labs 
site but could not find any. Can somebody send a code example of how to add a 
row to a datagrid programmatically?
 
Best 
regards
Ralf
 





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



   Visit your group "flexcoders" on the web. 
   To unsubscribe from this group, send an email to: [EMAIL PROTECTED] 
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.