views:

69

answers:

4

I would like to edit a cell by the row and column indexes so essentially do the following:

advDataGrid[2][3] = "Dogs"

so that I am setting the data grid row 2 and column 3 to Dogs. I cannot for the life of me figure out how to do this!

Side note: I need this because I am trying to allow the user to copy a section of an excel file to a section of an AdvancedDataGrid like Google Docs does. I am using this idea to do it: http://mannu.livejournal.com/348299.html

Thanks! Any help will be greatly appreciated!

A: 

Flex components are data driven, so you should modify the data provider of the grid.

an0nym0usc0ward
+1  A: 

In general you want to operate on the dataProvider rather than the presentation (AdvancedDataGrid). So in your case, I would get the item associated with the specified row from your dataProvider and modify whichever element is specified to "Dogs". So something like this: adg.dataProvider[row].someColumnData = "Dogs"

EDIT: "someColumnData" refers to whatever property you have set for the column to display. So when you defined your AdvancedDataGrid's columns, you set the 4th column to use the "someColumnData" property of the items in your dataProvider, and you want to change the value in the 4th column, then you'd set it as described above. Hope that clarifies things.

Wade Mueller
A: 

@Wade Mueller I'm confused about what is supposed to be someColumnData. Sorry I'm a total newbie to Adobe Flex/Actionscript!

eabrand
I updated my answer to hopefully clarify things for you.
Wade Mueller
Thanks! That does, I do have one more question though. In Debug mode I see that the dataprovider does get updated under the hood, but I can't seem to get that to show up on the screen. I added advDataGrid.validateNow(); and that still doesn't work. Thanks so much!
eabrand
Thank you for your help! I figured it out: var dp:ArrayCollection = advDataGrid.dataProvider as ArrayCollection;dp[1].CourseName = "Dogs";advDataGrid.dataProvider = dp;
eabrand
Sorry I pressed enter a little early. I accidentally created this question as an anonymous user so I'll ask an admin to put your answer as accepted. Thanks!
eabrand
A: 

What if you want to edit specific individual cells, eg I want to to keep running totals of some cells in other cells, IE: as a user edits I update whole columns.

Surely their must be a way to walk the array and get Column4.row6 = something.

Craig Mc