I have got a button in a datagrid using cellrendering. but I can't seem to modify it into my datagrid cart. Here is the code want I am doing wrong.
Any help will be great.
PHP Code:
//DELETE BUTTON
import mx.controls.DataGrid;
import mx.controls.gridclasses.DataGridColumn;
// Create DataGrid columns
var col = new DataGridColumn("TheButton");
col.headerText = "Delete";
col.width = 50;
col.cellRenderer = "ButtonCellRenderer"; // Assign custom cell renderer
grid_dg.addColumn(col);
var dp:Array = new Array();
grid_dg.dataProvider.addItem({TheButton:{label:"x"}});
//BASKET
var lvSend:LoadVars = new LoadVars();//do not change
lvSend.business = "chelnov63@hotmail.com"; //your paypal email address here
lvSend.currency_code = "GBP"; //the currency you would like to use
book = "bag1";
purse = "purse1"
//define items, their prices, quantity in basket and there associated movieclips
var aItem:Array = new Array();
aItem[book] = {price:15, quantity:0, size:10, pic:pic};
aItem[purse] = {price:25, quantity:0, size:30, pic:pic};
//-----------------------DO NOT CHANGE UNLESS FAMILIAR WITH ACTIONSCRIPT--------------------//
var totalPrice:Number;
//define drag and drop functionality
for (var i in aItem) {
var currentProduct:String = i;
aItem[i].item = currentProduct;
add1btn.onRelease = function() {
aItem[book].quantity++;
//update datagrid
updateDatagrid();
}
add2btn.onRelease = function() {
aItem[purse].quantity++;
//update datagrid
updateDatagrid();
}
}
deleteall.onRelease = function() {
aItem[currentProduct].quantity++;
basketInfo.dataProvider.removeAll();
}
deleteone.onRelease = function() {
basketInfo.dataProvider.removeItemAt(basketInfo.selectedIndex)
}
mcPaypal.onRelease = function():Void{
//send variables to paypal
//CONSTANTS
lvSend.cmd = "_cart";
lvSend.upload = "1";
var j:Number = 1;
for (var i in aItem) {
if(aItem[i].quantity > 0){
lvSend["item_name_"+j] = aItem[i].item;
lvSend["amount_"+j] = aItem[i].price;
lvSend["quantity_"+j] = aItem[i].quantity;
lvSend["size_"+j] = aItem[i].size;
j++;
}
}
lvSend.send("https://www.paypal.com/cgi-bin/webscr", "_self", "POST");
}
//--------------------------------------- functions ----------------------------------------------//
function updateDatagrid():Void{
totalPrice = 0;
var aBasket:Array = new Array();
for (var i in aItem) {
if(aItem[i].quantity > 0 ){
aBasket.push({Product: aItem[i].item, Size: aItem[i].size, Quantity: aItem[i].quantity, Price: aItem[i].price * aItem[i].quantity, Pic: aItem[i].pic});
totalPrice += aItem[i].quantity * aItem[i].price;
}
}
grid_dg.dataProvider = aBasket;
grid_dg.vScrollPolicy = "auto";
tTotal.text = totalPrice;
}