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 <
[EMAIL PROTECTED]> 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