I think I have a solution to my refresh problem.
I had tried this in my real project, but didn't really try it in my
small example that I sent to the message group. Perhaps I had a typo
or there was some other change that seems to make it work now, but
here is my solution:
// Basically, in the addRow function, dispatch an event that
// an item has been added to the collection. In my project,
// I hadn't included the event.location, but now that I include
// that it works.. and you don't even have to click on the header
// to see it!
private function addRow():void
{
if (frmName.text != "")
{
var newEmployee:Object = {name: frmName.text, email:
email.text, phone: phone.text};
var location:int = employees.length;
employees[location] = newEmployee;
var event:CollectionEvent = new
CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
event.items = new Array(newEmployee);
event.kind = CollectionEventKind.ADD;
event.location = location;
ArrayCollection(dg.dataProvider).dispatchEvent(event);
}
}
--- 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 --------------------~-->
Get to your groups with one click. Know instantly when new email arrives
http://us.click.yahoo.com/.7bhrC/MGxNAA/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/