Add newmodel.annotation.

 

Matt

 


From: [email protected] [mailto:[email protected]] On Behalf Of Kai Pradel
Sent: Monday, November 14, 2005 8:00 PM
To: [email protected]
Subject: [flexcoders] DataGrid question

 

I am new to Flex and am having a hell of a time figuring out how to use
the addItem method to add data to a DataGrid. I hope someone can give me
a pointer.
Here is what I am trying to do:

I have defined two models: one with static content and one that is bound
to text input fields that are inside of a panel. When the button is
pressed, I want to add the entered data to the samplegrid DataGrid. So
far it looks like it is adding *something* to the DataGrid since I can
see the scrollbars appear but nothing shows up in the grid itself.
What am I doing wrong?

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">

<mx:Script>
<![CDATA[
    public function makethechange():Void {
        samplegrid.addItem(newmodel);
        }
]]>
</mx:Script>

<mx:Model id="newmodel">
    <annotation>
        <name>{text1.text}</name>
        <time>{text2.text}</time>
        <comment>{text3.text}</comment>
    </annotation>
</mx:Model>

<mx:Model id="mymodel">
    <annotation>
        <name>My Name</name>
        <time>My Time</time>
        <comment>This is my comment</comment>
    </annotation>
    <annotation>
        <name>My Name</name>
        <time>My Time</time>
        <comment>This is my comment</comment>
    </annotation>
    <annotation>
        <name>My Name</name>
        <time>My Time</time>
        <comment>This is my comment</comment>
    </annotation>
</mx:Model>

<mx:HBox>
    <mx:Panel width="300" title="Test Grid">
        <mx:DataGrid id="samplegrid" width="100%" height="100%"
dataProvider="{ mymodel.annotation }"/>
    </mx:Panel>
    <mx:Panel width="300" title="Data Input">
        <mx:TextInput id="text1" />
        <mx:TextInput id="text2" />
        <mx:TextInput id="text3" />
        <mx:Button id="adbutton" label="Add Text" click="makethechange();"/>
    </mx:Panel>
</mx:HBox>


</mx:Application>


Thanks,
Kai




--
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




Reply via email to