First off, it's a bit difficult to debug as we don't have access to your service to get the data you are seeing.
Anyway, one thing I noticed is that in your function refreshBtn_clickHandler, you have the line: adg.dataProvider = "{getAllItemsCollection}"; This will not work as you intend. You are mixing ActionScript syntax with MXML syntax. I'm pretty sure that what you really want is: adg.dataProvider = getAllItemsCollection; --- In flexcoders@yahoogroups.com, awesome <cubesp...@...> wrote: > > > When I press delete I need to refresh datagrid to display changes. Currently > it displays changes only when I reload the page. > > I tried getAllItemsCollection.refresh(); but it only collapses grouping and > does not display changes. > > For testing purposes I created delete button and tried everything from > invalidatedisplaylist to reassigning dataprovider but with no luck. > > Any help would be appreciated. > > My code: > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" > minWidth="1024" minHeight="768" > xmlns:izdelkiservice="services.izdelkiservice.*"> > <mx:Script> > <![CDATA[ > import mx.events.AdvancedDataGridEvent; > import mx.controls.dataGridClasses.DataGridColumn; > import mx.controls.DataGrid; > import mx.events.DataGridEvent; > import mx.messaging.AbstractConsumer; > import mx.utils.ObjectUtil; > import mx.events.FlexEvent; > import mx.controls.Alert; > > public var clickedColumn:String; > > protected function > adg_creationCompleteHandler(event:FlexEvent):void > { > getAllItemsResult.token = > izdelkiService.getAllItems(); > } > > protected function > button_clickHandler(event:MouseEvent):void > { > createItemResult.token = > izdelkiService.createItem(izdelek); > } > > protected function > updateBtn_clickHandler(event:MouseEvent):void > { > updateItemResult.token = > izdelkiService.updateItem(izdelek2); > } > > protected function > deleteBtn_clickHandler(event:MouseEvent):void > { > deleteItemResult.token = > izdelkiService.deleteItem(izdelek2.id); > getAllItemsCollection.refresh(); > adg.dataProvider = adg.dataProvider; > } > > private var _dataField:String; > > private function > adg_headerReleaseHandler(event:AdvancedDataGridEvent):void > { > clickedColumn = event.dataField; > } > > private function sortNumeric(obj1:Object, > obj2:Object):int > { > return > ObjectUtil.numericCompare(obj1[clickedColumn],obj2[clickedColumn]); > > } > > private function sortKat(obj1:Object, obj2:Object):int > { > return > ObjectUtil.numericCompare(obj1.kat,obj2.kat); > } > > protected function > refreshBtn_clickHandler(event:MouseEvent):void > { > adg.dataProvider = null; > adg.dataProvider = "{getAllItemsCollection}"; > getAllItemsCollection.refresh(); > adg.validateDisplayList(); > adg.validateNow(); > adg.invalidateDisplayList(); > adg.invalidateList(); > } > ]]> > </mx:Script> > <mx:AdvancedDataGrid id="adg" designViewDataType="tree" width="100%" > creationComplete="adg_creationCompleteHandler(event)" > editable="false" > dataProvider="{getAllItemsCollection}" height="50%" > headerRelease="adg_headerReleaseHandler(event)"> > <mx:columns> > <mx:AdvancedDataGridColumn headerText="id" > dataField="id" > editable="false" sortCompareFunction="sortNumeric"/> > <mx:AdvancedDataGridColumn headerText="izdelek" > dataField="izdelek"/> > <mx:AdvancedDataGridColumn headerText="ime" > dataField="ime"/> > <mx:AdvancedDataGridColumn headerText="kat" > dataField="kat" > sortCompareFunction="sortNumeric"/> > <mx:AdvancedDataGridColumn headerText="opis" > dataField="opis"/> > <mx:AdvancedDataGridColumn headerText="datum" > dataField="datum"/> > <mx:AdvancedDataGridColumn headerText="vrstni_red" > dataField="vrstni_red" > sortCompareFunction="sortNumeric"/> > </mx:columns> > </mx:AdvancedDataGrid> > <mx:CallResponder id="getAllItemsResult" > result="getAllItemsCollection.refresh();"/> > <izdelkiservice:IzdelkiService id="izdelkiService" > destination="IzdelkiService" > endpoint="http://localhost/kerin_updater-debug/gateway.php" > fault="Alert.show(event.fault.faultString)" showBusyCursor="true" > source="IzdelkiService"/> > <mx:GroupingCollection id="getAllItemsCollection" > source="{getAllItemsResult.lastResult}"> > <mx:Grouping> > <mx:GroupingField name="kat" compareFunction="sortKat"/> > </mx:Grouping> > </mx:GroupingCollection> > <mx:HBox> > <mx:Form> > <mx:FormItem label="Id"> > <mx:TextInput id="idTextInput2" > text="{izdelek2.id}" enabled="false" > editable="false"/> > </mx:FormItem> > <mx:FormItem label="Izdelek"> > <mx:TextInput id="izdelekTextInput2" > text="{izdelek2.izdelek}"/> > </mx:FormItem> > <mx:FormItem label="Ime"> > <mx:TextInput id="imeTextInput2" > text="{izdelek2.ime}"/> > </mx:FormItem> > <mx:FormItem label="Kat"> > <mx:TextInput id="katTextInput2" > text="{izdelek2.kat}"/> > </mx:FormItem> > <mx:FormItem label="Opis"> > <mx:TextInput id="opisTextInput2" > text="{izdelek2.opis}"/> > </mx:FormItem> > <mx:FormItem label="Datum"> > <mx:TextInput id="datumTextInput2" > text="{izdelek2.datum}"/> > </mx:FormItem> > <mx:FormItem label="Vrstni_red"> > <mx:TextInput id="vrstni_redTextInput2" > text="{izdelek2.vrstni_red}"/> > </mx:FormItem> > <mx:HBox> > <mx:Button label="Update" id="updateBtn" > click="updateBtn_clickHandler(event)"/> > <mx:Button label="Delete" id="deleteBtn" > click="deleteBtn_clickHandler(event)"/> > <mx:Button label="Refresh" id="refreshBtn" > click="refreshBtn_clickHandler(event)"/> > </mx:HBox> > </mx:Form> > <mx:Form defaultButton="{button}"> > <mx:FormItem label="Id"> > <mx:TextInput id="idTextInput" > text="{izdelek.id}" editable="false" > enabled="false" /> > </mx:FormItem> > <mx:FormItem label="Izdelek"> > <mx:TextInput id="izdelekTextInput" > text="{izdelek.izdelek}"/> > </mx:FormItem> > <mx:FormItem label="Ime"> > <mx:TextInput id="imeTextInput" > text="{izdelek.ime}"/> > </mx:FormItem> > <mx:FormItem label="Kat"> > <mx:TextInput id="katTextInput" > text="{izdelek.kat}"/> > </mx:FormItem> > <mx:FormItem label="Opis"> > <mx:TextInput id="opisTextInput" > text="{izdelek.opis}"/> > </mx:FormItem> > <mx:FormItem label="Datum"> > <mx:TextInput id="datumTextInput" > text="{izdelek.datum}"/> > </mx:FormItem> > <mx:FormItem label="Vrstni_red"> > <mx:TextInput id="vrstni_redTextInput" > text="{izdelek.vrstni_red}"/> > </mx:FormItem> > <mx:Button label="CreateItem" id="button" > click="button_clickHandler(event)"/> > </mx:Form> > </mx:HBox> > > <izdelkiservice:Izdelek id="izdelek" > vrstni_red="{vrstni_redTextInput.text}" izdelek="{izdelekTextInput.text}" > datum="{datumTextInput.text}" ime="{imeTextInput.text}" > kat="{katTextInput.text}" opis="{opisTextInput.text}"/> > <mx:Binding source="idTextInput.text" destination="izdelek.id"/> > <mx:CallResponder id="createItemResult"/> > <izdelkiservice:Izdelek id="izdelek2" izdelek="{izdelekTextInput2.text}" > ime="{imeTextInput2.text}" kat="{katTextInput2.text}" > datum="{datumTextInput2.text}" opis="{opisTextInput2.text}" > vrstni_red="{vrstni_redTextInput2.text}"/> > > <mx:Binding source="idTextInput2.text" destination="izdelek2.id"/> > <mx:Binding source="adg.selectedItem as Izdelek" > destination="izdelek2"/> > <mx:CallResponder id="updateItemResult"/> > <mx:CallResponder id="deleteItemResult"/> > > </mx:Application> > > -- > View this message in context: > http://www.nabble.com/advanced-datagrid-refresh-tp24710773p24710773.html > Sent from the FlexCoders mailing list archive at Nabble.com. >