This content has been marked as final. Show 3 replies
You use a dataprovider to fill the datagrid right (say if an Arraycollection ?) ?
Simply do work on that dataprovider using the Arraycollection functions
To get the selected item in your DG:
var myObj:Object = new Object();
myObj = myArrayCollection.getItemAt(myDataGrid.selectedIndex)
Alert.show(myObj.firstname + " is the selected firstname in my DG");
To delete an item in the Arraycollection(and hence the DG):
Once you do work on your arraycollection, because its a dataprovider to your DG the DG will reflect those changes...
This stuff is all pretty new to me. Got the removal to work. I'm going to run to class and see if I can get the edit function to work when I get back.
When editing in your DG, once you have the new , updated data
you need to use the setItemAt function on your Arraycollection.
i.e here is a snippet :
var am:AssessmentMark = new AssessmentMark();
am.***_mark = e.target.the_val;
am.id = AC_class_students_marks.getItemAt(DG_class_students.selectedIndex).id;
am.rpt_period_id = 1;
am.sc_id = StudentClass(COMBO_my_classes.selectedItem).sc_id;
var obj:Object = new Object();
obj = AC_assessmentmarks.getItemAt(b);
Basically i create a new "am" object and fill its properties with whatever.
Once I've done that I use this update "am" object and setItem that object into my arraycollection, then call the itemupdated function to tell it that something has been updated so you see the change in your DG...