>From a previous post, it was determined that updating an array, used 
with an ArrayCollection, doesn't bind well to a view.  Paul Williams 
suggested doing something like this:

[Bindable]
public var employees : ArrayCollection = new ArrayCollection();

[Bindable]
public var employeesDP : ListCollectionView = new ListCollectionView
(employees);

public function addRow() : void
{
   // not sure this if the correct syntax for this
   employees.addItem( name: frmName.text,email: email.text, phone: 
phone.text );
}

<mx:DataGrid id="dg" width="100%" height="100%" 
dataProvider="{employeesDP}">

You might not be able to do it this way because of your design 
constraints, but it might help.

Tim Hoff

--- In [email protected], "Scott Romer" <[EMAIL PROTECTED]> wrote:
>
> Thanks Mike.  You've basically come to the same conclusion I 
have.  I
> really appreciate your time in trying to figure this out as well..
> 
> If you ever get any other ideas, feel free to let me know.  I'm 
just
> planning to move on for now.. (the customer really won't notice 
they
> they have to add an item twice to see it, right? hehehe)
> 
> -scott
> 
> 
> --- In [email protected], "Michael Schmalle"
> <teoti.graphix@> wrote:
> >
> > Hi again,
> > 
> > I did another test,
> > 
> > When you add
> > 
> > dg.invalidateList();
> > 
> > You click addRow(), the first itme nothing happens, you click 
addRow()
> > again, both new items show up in the dg.
> > 
> > I havn't worked to much with the lists but, this dosn't seem 
like a
> proper
> > behavior. Bug Adobe?
> > 
> > Peace, Mike
> > 
> > On 6/13/06, Michael Schmalle <teoti.graphix@> wrote:
> > >
> > > Hi,
> > >
> > > I just looked at the source for the DataGrid,
> > >
> > > When you press a header, all they are doing is calling
> collection.refresh
> > > ().
> > >
> > > I don't understand why it is not getting updated instantly.
> > >
> > > Peace, Mike
> > >
> > >
> > > On 6/13/06, Michael Schmalle <teoti.graphix@> wrote:
> > > >
> > > > Hi,
> > > >
> > > > I tried you example
> > > >
> > > > this works.. kindof
> > > >
> > > > ICollectionView(dg.dataProvider).refresh();
> > > >
> > > > It dosn't seem to work until you hit a header, then it works 
always.
> > > >
> > > > Peace, Mike
> > > >
> > > >
> > > > On 6/13/06, Scott Romer < swromer@> wrote:
> > > > >
> > > > >    Hello -
> > > > >
> > > > > I have some design constraints which is forcing me to use 
an Array
> > > > > behind the scenes for updating a dataGrid. In either case, 
I
> have a
> > > > > simpler version of the code here, that basically follows an
> example in
> > > > > the docs except that the update is made directly to the 
array
> rather
> > > > > than using the suggested addItemAt(), setItemAt() methods.
> > > > >
> > > > > I have confirmed that addItemAt and setItemAt do cause the
> dataGrid to
> > > > > redraw, however, I need to find what event I need to 
trigger
> and/or
> > > > > listen for to get the redraw to work if I am updating the 
array
> > > > > myself.
> > > > >
> > > > > See the following code:
> > > > > [---START CODE---]
> > > > > <?xml version="1.0" encoding="utf-8"?>
> > > > >
> > > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> > > > > backgroundAlpha="0"
> > > > > initialize="initImpl()">
> > > > >
> > > > > <mx:Script>
> > > > >
> > > > > import mx.collections.ArrayCollection;
> > > > >
> > > > > [Bindable]
> > > > > public var employees:Array = new Array();
> > > > >
> > > > > private function initImpl():void
> > > > > {
> > > > > dg.dataProvider = new ArrayCollection(employees);
> > > > > }
> > > > >
> > > > > private function addRow():void
> > > > > {
> > > > > if (frmName.text != "")
> > > > > {
> > > > > employees[employees.length] = {name: frmName.text,
> > > > > email: email.text, phone: phone.text};
> > > > > }
> > > > > }
> > > > >
> > > > > private function updateRow():void
> > > > > {
> > > > > if (dg.selectedIndex != -1)
> > > > > {
> > > > > employees[dg.selectedIndex] = {name: frmName.text,
> > > > > email: email.text, phone: phone.text};
> > > > > }
> > > > > }
> > > > >
> > > > > </mx:Script>
> > > > >
> > > > > <mx:HBox width="100%" height="100%">
> > > > >
> > > > > <mx:DataGrid id="dg" width="100%" height="100%">
> > > > > <mx:columns>
> > > > > <mx:Array>
> > > > > <mx:DataGridColumn dataField="name"
> > > > > headerText="Name"/>
> > > > > <mx:DataGridColumn dataField="phone"
> > > > > headerText="Phone"/>
> > > > > <mx:DataGridColumn dataField="email"
> > > > > headerText="Email"/>
> > > > > </mx:Array>
> > > > > </mx:columns>
> > > > > </mx:DataGrid>
> > > > >
> > > > > <mx:Form width="100%" height="100%">
> > > > > <mx:FormItem label="Name">
> > > > > <mx:TextInput id="frmName" width="200"
> > > > > text="{dg.selectedItem.name}"/>
> > > > > </mx:FormItem>
> > > > > <mx:FormItem label="Email">
> > > > > <mx:TextInput id="email" width="200"
> > > > > text="{dg.selectedItem.email}"/>
> > > > > </mx:FormItem>
> > > > > <mx:FormItem label="Phone">
> > > > > <mx:TextInput id="phone" width="200"
> > > > > text="{dg.selectedItem.phone}"/>
> > > > > </mx:FormItem>
> > > > > <mx:FormItem>
> > > > > <mx:HBox>
> > > > > <mx:Button label="Update" click="updateRow()"/>
> > > > > <mx:Button label="Add" click="addRow()"/>
> > > > > </mx:HBox>
> > > > > </mx:FormItem>
> > > > > </mx:Form>
> > > > >
> > > > > </mx:HBox>
> > > > >
> > > > > </mx:Application>
> > > > >
> > > > > [---END CODE---]
> > > > >
> > > > > I've tried listening for collection events and calling
> > > > > invalidateDisplayList(), but that doesn't seem to work. 
Any other
> > > > > ideas?
> > > > >
> > > > > Thanks,
> > > > > -scott
> > > > >
> > > > >  
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > What goes up, does come down.
> > > >
> > >
> > >
> > >
> > > --
> > > What goes up, does come down.
> > >
> > 
> > 
> > 
> > -- 
> > What goes up, does come down.
> >
>






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Everything you need is one click away.  Make Yahoo! your home page now.
http://us.click.yahoo.com/AHchtC/4FxNAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to