drkstr
09-28-2007, 05:31 AM
**EDIT: Resolved **
I need to be able to modify a property of the selectedItem in the DataGrid and have the property in my data provider update as well (which it should do if selectedItem is a reference to the data provider's item). However, when I update a property of the class by referencing it with DataGrid.selectedItem, it doesn't seem to update my data provider's class property.
Does the DataGrid.selectedItem return a copy of the class instance, or am I just doing something wrong somewhere else in the app?
<mx:DataGrid id="idBoardGrid" width="100%" height="100%"
change="onBoardChange( BoardModel(idBoardGrid.selectedItem) );"
editable="true" rowCount="5"
dataProvider="{myBoardManager.boardCollection}" />
<mx:Button label="Save Selected"
click="onSaveSelectedClicked( BoardModel(idBoardGrid.selectedItem) );" />
private function onSaveSelectedClicked( boardModel:BoardModel ): void {
//myBoardManager.saveBoard(boardModel);
boardModel.dataChanged = false;
for each( var board:BoardModel in myBoardManager.boardCollection ) {
trace('Data Changed? '+board.dataChanged)
}
}
Before I click the button, the 1st (0) item is selected and it's dataChagned property is true. Here is the output of the trace statement:
Data Changed? true
Data Changed? false
The livedocs say the selectedItem is a "A reference to the selected item in the data provider", but this doesn't seem to be the case. Any recommendations on how to get a reference to the original class instance through the data grid?
Thanks for your time!
...aaron
I need to be able to modify a property of the selectedItem in the DataGrid and have the property in my data provider update as well (which it should do if selectedItem is a reference to the data provider's item). However, when I update a property of the class by referencing it with DataGrid.selectedItem, it doesn't seem to update my data provider's class property.
Does the DataGrid.selectedItem return a copy of the class instance, or am I just doing something wrong somewhere else in the app?
<mx:DataGrid id="idBoardGrid" width="100%" height="100%"
change="onBoardChange( BoardModel(idBoardGrid.selectedItem) );"
editable="true" rowCount="5"
dataProvider="{myBoardManager.boardCollection}" />
<mx:Button label="Save Selected"
click="onSaveSelectedClicked( BoardModel(idBoardGrid.selectedItem) );" />
private function onSaveSelectedClicked( boardModel:BoardModel ): void {
//myBoardManager.saveBoard(boardModel);
boardModel.dataChanged = false;
for each( var board:BoardModel in myBoardManager.boardCollection ) {
trace('Data Changed? '+board.dataChanged)
}
}
Before I click the button, the 1st (0) item is selected and it's dataChagned property is true. Here is the output of the trace statement:
Data Changed? true
Data Changed? false
The livedocs say the selectedItem is a "A reference to the selected item in the data provider", but this doesn't seem to be the case. Any recommendations on how to get a reference to the original class instance through the data grid?
Thanks for your time!
...aaron