[flexcoders] Re: Datagrid update woes(blank rows)
ok here goes. private function resultHandler(evt:ResultEvent):void { dataProvider = new ArrayCollection ( ArrayUtil.toArray(evt.result) ); // same as: evt.result.toString(); } public function sendResultHandler(evt:ResultEvent):void { dataProvider.addItem(ArrayUtil.toArray(evt.result)); dataProvider.refresh(); } first function is called when the app is loaded. second function is called when i add a new user to the database
Re: [flexcoders] Re: Datagrid update woes(blank rows)
trace the evt.result using the ObjectUtil.toString() (note: you will need to import mx.utils.ObjectUtil to do this) and lets see what is coming back from the server. most likely the reason you are getting a blank row is that what is coming back does not match what the grid is expecting. On 2/11/07, munene_uk [EMAIL PROTECTED] wrote: ok here goes. * private function resultHandler(evt:ResultEvent):void { dataProvider = new ArrayCollection ( ArrayUtil.toArray( evt.result) ); // same as: evt.result.toString(); } public function sendResultHandler(evt:ResultEvent):void { dataProvider.addItem(ArrayUtil.toArray(evt.result)); dataProvider.refresh(); } *first function is called when the app is loaded. second function is called when i add a new user to the database -- http://indeegrumpee.spaces.live.com/
[flexcoders] Re: Datagrid update woes(blank rows)
this is what i got [SWF] F:\Adobe\Flex Builder 2\Projects\bin\Savo_Course_Manager2-debug.swf - 1,103,465 bytes after decompression warning: unable to bind to property 'SURNAME' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'POSTCODE' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'PHONENO' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'STUDENTNO' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'STREET' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'BIRTH_DATE' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'HOUSENO' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'FIRSTNAME' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'TOWN' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'EMAIL' on class 'Object' (class is not an IEventDispatcher) (Array)#0 [0] (Object)#1 BIRTH_DATE = 1985-01-01 EMAIL = [EMAIL PROTECTED] FIRSTNAME = as HOUSENO = 40 PHONE = PHONENO = 1240235402-9 POSTCODE = sdf STREET = asf STUDENTNO = 41 SURNAME = ap TOWN = sdf
Re: [flexcoders] Re: Datagrid update woes(blank rows)
try what I suggested in your addItem On 2/11/07, munene_uk [EMAIL PROTECTED] wrote: this is what i got *[SWF] F:\Adobe\Flex Builder 2\Projects\bin\Savo_Course_Manager2-debug.swf- 1,103,465 bytes after decompression warning: unable to bind to property 'SURNAME' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'POSTCODE' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'PHONENO' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'STUDENTNO' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'STREET' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'BIRTH_DATE' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'HOUSENO' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'FIRSTNAME' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'TOWN' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'EMAIL' on class 'Object' (class is not an IEventDispatcher) (Array)#0 [0] (Object)#1 BIRTH_DATE = 1985-01-01 EMAIL = [EMAIL PROTECTED] FIRSTNAME = as HOUSENO = 40 PHONE = PHONENO = 1240235402-9 POSTCODE = sdf STREET = asf STUDENTNO = 41 SURNAME = ap TOWN = sdf * -- http://indeegrumpee.spaces.live.com/
[flexcoders] Re: Datagrid update woes(blank rows)
how do i find out the index of the last item in order to use addItemAt(evt2.result,index); (if that makes sense!!) --- In flexcoders@yahoogroups.com, Clint Tredway [EMAIL PROTECTED] wrote: try what I suggested in your addItem On 2/11/07, munene_uk [EMAIL PROTECTED] wrote: this is what i got *[SWF] F:\Adobe\Flex Builder 2\Projects\bin\Savo_Course_Manager2-debug.swf- 1,103,465 bytes after decompression warning: unable to bind to property 'SURNAME' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'POSTCODE' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'PHONENO' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'STUDENTNO' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'STREET' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'BIRTH_DATE' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'HOUSENO' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'FIRSTNAME' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'TOWN' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'EMAIL' on class 'Object' (class is not an IEventDispatcher) (Array)#0 [0] (Object)#1 BIRTH_DATE = 1985-01-01 EMAIL = [EMAIL PROTECTED] FIRSTNAME = as HOUSENO = 40 PHONE = PHONENO = 1240235402-9 POSTCODE = sdf STREET = asf STUDENTNO = 41 SURNAME = ap TOWN = sdf * -- http://indeegrumpee.spaces.live.com/
Re: [flexcoders] Re: Datagrid update woes(blank rows)
myGrid.dataProvider.length On 2/11/07, munene_uk [EMAIL PROTECTED] wrote: how do i find out the index of the last item in order to use addItemAt(evt2.result,index); (if that makes sense!!) --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Clint Tredway [EMAIL PROTECTED] wrote: try what I suggested in your addItem On 2/11/07, munene_uk [EMAIL PROTECTED] wrote: this is what i got *[SWF] F:\Adobe\Flex Builder 2\Projects\bin\Savo_Course_Manager2-debug.swf- 1,103,465 bytes after decompression warning: unable to bind to property 'SURNAME' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'POSTCODE' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'PHONENO' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'STUDENTNO' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'STREET' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'BIRTH_DATE' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'HOUSENO' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'FIRSTNAME' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'TOWN' on class 'Object' (class is not an IEventDispatcher) warning: unable to bind to property 'EMAIL' on class 'Object' (class is not an IEventDispatcher) (Array)#0 [0] (Object)#1 BIRTH_DATE = 1985-01-01 EMAIL = [EMAIL PROTECTED] m%40mail.com FIRSTNAME = as HOUSENO = 40 PHONE = PHONENO = 1240235402-9 POSTCODE = sdf STREET = asf STUDENTNO = 41 SURNAME = ap TOWN = sdf * -- http://indeegrumpee.spaces.live.com/ -- http://indeegrumpee.spaces.live.com/
[flexcoders] Re: Datagrid update woes(blank rows)
ive done as suggested however i still get a blank row public function sendResultHandler(evt2:ResultEvent):void { var index:int = dg.dataProvider.length; dg.dataProvider.addItemAt(evt2.result,index); trace(ObjectUtil.toString(evt2.result) ); dg.dataProvider.refresh(); } funny thing is that if i do this public function sendResultHandler(evt2:ResultEvent):void { dg. dataProvider = new ArrayCollection ( ArrayUtil.toArray(evt2.result) ); var index:int = dg.dataProvider.length; dg.dataProvider.addItemAt(evt2.result,index); trace(ObjectUtil.toString(evt2.result) ); dg.dataProvider.refresh(); } it correctly populates the datagrid with the correct record so im assuming that the data being retrieved is correct, so the problem must be the addItemAt() . im really taking a stab in the dark here but i really appreciate the help you've given so far.
Re: [flexcoders] Re: Datagrid update woes(blank rows)
OK, I think I see what your problem is. You said that your PHP script returns this, which is a nested array. (Array)#0 [0] (Object)#1 BIRTH_DATE = 1985-01-01 EMAIL = [EMAIL PROTECTED] FIRSTNAME = as HOUSENO = 40 PHONE = PHONENO = 1240235402-9 POSTCODE = sdf STREET = asf STUDENTNO = 41 SURNAME = ap TOWN = sdf It's obvious now that you need to add the first item (which is at the index of zero), instead of the entire array, to the dataProvider. See the result[0] below. Hope that makes sense. And just use addItem instead of addItemAt if you just want to place it at the end of the array. public function sendResultHandler(evt:ResultEvent):void { var row:Array = ArrayUtil.toArray(evt.result[0]); dataProvider.addItem(row); dataProvider.refresh(); } Now you might have to change this line: var row:Array = ArrayUtil.toArray(evt.result[0]); to fit exactly what you want. It might work as is though. Cheers, Adam - Original Message - From: munene_uk To: flexcoders@yahoogroups.com Sent: Monday, February 12, 2007 8:41 AM Subject: [flexcoders] Re: Datagrid update woes(blank rows) ive done as suggested however i still get a blank row public function sendResultHandler(evt2:ResultEvent):void { var index:int = dg.dataProvider.length; dg.dataProvider.addItemAt(evt2.result,index); trace(ObjectUtil.toString(evt2.result) ); nbsp; dg.dataProvider.refresh(); } funny thing is that if i do this public function sendResultHandler(evt2:ResultEvent):void { dg. dataProvider = new ArrayCollection ( ArrayUtil.toArray(evt2.result) ); var index:int = dg.dataProvider.length; dg.dataProvider.addItemAt(evt2.result,index); trace(ObjectUtil.toString(evt2.result) ); dg.dataProvider.refresh(); } it correctly populates the datagrid with the correct record so im assuming that the data being retrieved is correct, so the problem must be the addItemAt() . im really taking a stab in the dark here but i really appreciate the help you've given so far.
[flexcoders] Re: Datagrid update woes(blank rows)
great news!!...ive gone back to using remotingConnection and your method worksthank you so much for all your input! public function onSendResult(result :Array) : void { if(!result) return; dg.dataProvider.addItem(result[0]); dg.dataProvider.refresh(); }