Hi Sean,
It worked..Thank you very much
Thanks
Santosh
 

<strong><font color="#ff9f40">Ekam sat vipra bahuda nudanti" -- God is one 
scholars perceive
differently - Vedas





</font></strong>



----- Original Message ----
From: Sean Clark Hess <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, July 2, 2008 9:42:02 AM
Subject: Re: [flexcoders] display text input values in datagrid


Ah, I understand.  You should use an ArrayCollection.   If you set the 
dataProvider of the datagrid to the array collection, you can update or change 
the collection's source at any time. 

So, you'd want something like this:


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe. com/2006/ mxml" layout="absolute">
    
    <mx:Script>
        <![CDATA[
            import mx.collections. ArrayCollection;
            
            [Bindable]
            private var collection:ArrayCol lection = new ArrayCollection( new 
Array());
        
            private function val():void
            {
                // will add one row to the collection you are already watching
                collection.source. push({tt1: pp1.text, tt2:pp2.text, 
tt3:pp3.text} );
            }
        ]]>
    </mx:Script>
    
    <mx:TextInput x="170" y="73" id="pp1"/>
    <mx:TextInput x="170" y="73" id="pp2"/>
    <mx:TextInput x="170" y="73" id="pp3"/>
    
    <!-- I bind the dataProvider to the collection here -->
    <mx:DataGrid x="207" y="144" id="dg" dataProvider='{collection}'>
        <mx:columns>
            <mx:DataGridColumn headerText="Column 1" dataField="tt1"/>
            <mx:DataGridColumn headerText="Column 2" dataField="tt2"/>
            <mx:DataGridColumn headerText="Column 3" dataField="tt3"/>
        </mx:columns>
    </mx:DataGrid>
    <mx:Button x="85" y="134" label="Button" click="val()"/>
    
</mx:Application>


On Wed, Jul 2, 2008 at 10:36 AM, Santhosh Garlapad <santhoshgarlapad@ 
yahoo.com> wrote:

Hi Sean,
I m working on Shopping cart application.
I have Button called ADD another Item.If i click on that button the all the 
shopping cart item details shold be displayed in the datagrid.
Your solution is perfect if i have only one row item in the datagrid.If i click 
Add another items multiple times and alll the text input values should be 
displayed in the datagrid.
Say i clicked the add another item 20 times ,,the datagrid should contains 20 
items in that(with textinput values)
 
 
The sample datagrid as follows:
column1 col2    col3 
text1    text 2   text3 --button Clicked second time
texta    textb    textc--button Clicked first time


 
Thanks
Santosh


 


----- Original Message ----
From: Sean Clark Hess <[EMAIL PROTECTED] com>
To: [EMAIL PROTECTED] ups.com

Sent: Wednesday, July 2, 2008 9:27:00 AM
Subject: Re: [flexcoders] display text input values in datagrid


I'm not sure what you mean, or why you would want to "push them down."  but you 
can add more rows by adding more rows to the array... The datagrid just 
displays what is in the array.  So, just copy that values.push( ) line, and put 
different (or blank) values in . 

~sean


On Wed, Jul 2, 2008 at 10:24 AM, Santhosh Garlapad <santhoshgarlapad@ 
yahoo.com> wrote:

Hi Sean,
 
Thannks for the suggestion.
How can push the values down if i want to add few more rows in the datagrid?
Do i need to loo through the datagrid?
 
Thanks
Santosh
 






----- Original Message ----
From: Sean Clark Hess <[EMAIL PROTECTED] com>

To: [EMAIL PROTECTED] ups.com
Sent: Wednesday, July 2, 2008 8:32:51 AM
Subject: Re: [flexcoders] display text input values in datagrid


You want to change your val() function to something more like this. 


 private function val():void
            {
                var values:Array = new Array();
                    
                    // this is only one row
                    values.push( {tt1:pp1. text, tt2:pp2.text, tt3:pp3.text} );
                    
                    
                dg.dataProvider= values;
            }

The dataProvider for a datagrid should be something like an array (because of 
all the rows).  Each row should be an object with fields (like "tt1" "tt2" and 
"tt3")


On Tue, Jul 1, 2008 at 8:43 PM, Santhosh Garlapad <santhoshgarlapad@ yahoo.com> 
wrote:

Hi guys,

i m a beginner to flex development.

i have few text input fieds and when i click add button all the text input 
values to be displayed in datagrid.

if i add few more items into the datagrid the values the new values display 
first

sample datagrid as follows;
column1 col2    col3 
text1    text 2   text3
texta    textb    textc

please find the sample code below''

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe. com/2006/ mxml" layout="absolute">
    
    <mx:Script>
        <![CDATA[
            private function val():void
            
            {
                dg.dataProvider= pp1.text;
            }
        ]]>
    </mx:Script>
    
    <mx:TextInput x="170" y="73" id="pp1"/>
    <mx:TextInput x="170" y="73" id="pp2"/>
    <mx:TextInput x="170" y="73" id="pp3"/>
    <mx:DataGrid x="207" y="144" id="dg">
        <mx:columns>
            <mx:DataGridColumn headerText="Column 1" dataField="tt1"/>
            <mx:DataGridColumn headerText="Column 2" dataField="tt2"/>
            <mx:DataGridColumn headerText="Column 3" dataField="tt3"/>
        </mx:columns>
    </mx:DataGrid>
    <mx:Button x="85" y="134" label="Button" click="val()"/>
    
</mx:Application>

can anyone help with the script..

thanks
san

 





 


      

Reply via email to