If you are working with an editable data grid component
and as you reach the last column you need to add the next row
so that the next set of informations can be add do this:
drag a datagrid component to the stage
make you data grid big enough since am not goin to give column width and all
into the code .
once the data is ready to send it also checks for any null rows.here I have only checked for
a specific value before deleting a row.
The context Menu helps to delete any selcted row.
once you delete a row make sure that you reflect the change in the dataprovider
and reload the entire data with the dataprovider if you want to edit the DataGrid agian.
give an instance name : myDataGrid_dg
and give some life with this action script :
---------------------------------------------------------
import mx.controls.gridclasses.DataGridColumn ;
var my_cm:ContextMenu = new ContextMenu();
my_cm.hideBuiltInItems();
var menuItem_cmi:ContextMenuItem = new ContextMenuItem("delete_handle", deleteHandler);
my_cm.customItems.push(menuItem_cmi);
this.menu = my_cm;
function deleteHandler() {
(myDataGrid_dg.removeItemAt(myDataGrid_dg.selectedIndex));
}
data_array = new Array();
data_array =[{name:"", price:"",number:""}];
myDataGrid_dg.dataProvider = data_array;
// this is the simplest way to make a DG ready
myDataGrid_dg.editable =true;
//make the DG editable
var num =0;
listen = new Object();
// a listener object is add to trigger events
listen.cellFocusOut = function(obj){
if(obj.columnIndex ==2){
num ++;
var obj ={name:"", price:"",number:""}
myDataGrid_dg.addItemAt(num,obj);
//here you can also use
//myDataGrid_dg.addItem(obj);
}
}
myDataGrid_dg.addEventListener("cellFocusOut",listen);
send_btn.onRelease=function(){
trace(myDataGrid_dg.length);
for(i = myDataGrid_dg.length ; i >= 0 ;i-- ){
if((myDataGrid_dg.getItemAt(i).price) == undefined||(myDataGrid_dg.getItemAt(i).price) == ""){
myDataGrid_dg.removeItemAt(i);
}
}
}
//each time a cell gets out of focus the event is triggered
-------------------------------------------------------------
Thursday, June 09, 2005
Subscribe to:
Posts (Atom)