Just a little more information, if I look at my IIS logs, I do not see the httpsrv request after each additem.. but the function does run.. I'm a bit stomped on this one.
--- In [email protected], "estidecalisse" <[EMAIL PROTECTED]> wrote: > > Well I tried using that datagrid1.invalidatelist() in a few places in > the code and even added a button to do it, but it seems to do nothing > at all... > > > > --- In [email protected], Sherif Abdou <sherif626@> wrote: > > > > dataGridName.invalidateList(); > > > > ----- Original Message ---- > > From: estidecalisse <estidecalisse@> > > To: [email protected] > > Sent: Thursday, March 20, 2008 9:01:45 PM > > Subject: [flexcoders] Problem refreshing a datagrid after adding > items to Database > > > > Hi everyone, > > > > I've been playing around with this code for a few hours now and I just > > can't figure out how to get the datagrid to refresh after I have sent > > a new item to the database. > > > > I've seen many posts about using an arraycollection as a dataprovider > > for the datagrid, which is what I'm doing. > > > > Essentially, the httpsrv service gets the data from the server, and > > then the addtoarray function populates the arraycollection. > > > > when the data entered in the very basic form gets sent back, the > > function also calls the httpsrv again to re-populate the > > arraycollection. This is where things don't seem to work as they > > should. Perhaps my logic is wrong ;-) but I know that the httpsrv > > runs everytime because I added a quick alert pop-up to tell me it's > > running. > > > > any pointers will be appreciated! > > > > <?xml version="1.0" encoding="utf- 8"?> > > <mx:Application xmlns:mx="http://www.adobe. com/2006/ mxml" > > layout="absolute" creationComplete= "httpsrv. send()"> > > > > <mx:Script> > > <![CDATA[ > > import mx.controls. Alert; > > import mx.rpc.events. ResultEvent; > > import mx.collections. ArrayCollection; > > > > private function checksuccess( evt:ResultEvent) :void > > { > > labelsuccess. text = evt.result.success; > > labelsuccess2. text = ""; > > httpsrv.send( ); > > myusers.refresh( ); > > datagrid1.dataProvi der=myusers; > > > > > > } > > [Bindable] > > private var myusers:ArrayCollec tion = new > > ArrayCollection( ); > > > > private function addtoarray(evt: ResultEvent) :void > > { > > > > myusers=(evt. result.stuff. people); > > mx.controls. Alert.show( "inside Addarray > > right now"); > > labelsuccess2. text = labelsuccess. text + > > "addtoarray ran..."; > > /* <mx:DataGrid id="datagrid1" enabled="true" > > dataProvider= "{httpsrv. lastResult. stuff.people} " editable="false" > > width="60%" height="85%" verticalCenter= "-9" themeColor=" #596DD3" > > textAlign="center" left="65" alpha="0.84" borderThickness= "0" > > alternatingItemColo rs="[#F7F7F7, #FFFFFF]"> */ > > } > > ]]> > > </mx:Script> > > > > <mx:Panel width="90%" height="90%" layout="absolute" > > themeColor=" #FF003C" verticalAlign= "top" horizontalCenter= "-16" > > verticalCenter= "-5"> > > <mx:DataGrid id="datagrid1" enabled="true" dataProvider= "{myusers} " > > editable="false" width="611" height="519" themeColor=" #596DD3" > > textAlign="center" alpha="0.84" borderThickness= "0" > > alternatingItemColo rs="[#F7F7F7, #FFFFFF]" x="0" y="0"> > > <mx:columns> > > <mx:DataGridColumn headerText=" Database ID" > > dataField="id" /> > > <mx:DataGridColumn headerText=" Client Name" > > dataField="name" /> > > <mx:DataGridColumn headerText=" Client Email" > > dataField="email" /> > > </mx:columns> > > </mx:DataGrid> > > <mx:Form width="308" height="154" x="635" y="10"> > > <mx:FormHeading label="Add Item"/> > > <mx:FormItem label="Name" required="true" > > > <mx:TextInput id="input_name" editable="true" > > enabled="true" /> > > </mx:FormItem> > > <mx:FormItem label="E-Mail" required="true" > > > <mx:TextInput id="input_email" editable="true" > > enabled="true" /> > > </mx:FormItem> > > <mx:Button label="Button" labelPlacement= "left" > > click="additem. send()"/> > > </mx:Form> > > <mx:Label width="256" id="labelsuccess" x="655" y="172" > > color="#2DB834" /> > > <mx:Label x="655" y="208" width="256" id="labelsuccess2" /> > > </mx:Panel> > > <mx:HTTPService id="httpsrv" > > url="http://cybweb01: 82/dev/flex/ allo.asp? task=data" useProxy="False" > > result="addtoarray( event)" showBusyCursor= "true"> > > > > </mx:HTTPService> > > > > <mx:HTTPService id="additem" > > url="http://cybweb01: 82/dev/flex/ allo.asp? task=additem" method="POST" > > useProxy="False" result="checksucces s(event)" > > > <mx:request xmlns=""> > > <name>{input_ name.text} </name> > > <email>{input_ email.text} </email> > > </mx:request> > > > > </mx:HTTPService> > > </mx:Application> > >

