PDA

View Full Version : Datagrid


DekaFlash
08-22-2005, 12:11 PM
To anyone that can assist me, thanks in advance.

I have a editable datagrid that is populated based on a combo box selection via a Web Service.

The edits made to the grid can be saved but not directly.

So it is necessary to store the modifications in an array, unfortunately the elements of the array are not been succesfully
passed back to the Web Service.

var AmendedRowNumber_Array = new Array();
- Defined at root level for the purpose of storing the modified rows of a datagrid.

The actionscript below exists within the Datagrid and is used to track edits.

When one of the cells within the grid is edited, the debugging statement _root.valueofyes1.text = "Pushed"; proves
it has been pushed onto the array.

this.editable = true;
var cellmodified = new Object();
// var AmendedRowNumber_Array = new Array();

cellmodified.cellEdit = function(event)
{
_root.valueofyes1.text = "Modified";
var col_name = _root.statementsgrid.getColumnAt(event.columnIndex ).columnName;

var myvalue = _root.statementsgrid.getItemAt(event.itemIndex)[col_name];
_root.wsmessage.text = "The value of the cell " + col_name + " was " + event.oldValue + " and is now " + myvalue + "";
var yes = {name:statementsgrid.getItemAt(event.columnIndex). confirmed, value:newValue_num};

this["ChangedCell"+col_name+(event.itemIndex)] = event.oldValue;

// _root.valueofyes.text = ["ChangedCell"+col_name+(event.itemIndex)];
// _root.valueofyes1.text = this["ChangedCell"+col_name+(event.itemIndex)];

if (_root.valueofyes1.text eq event.oldValue)
{
// _root.valueofyes2.text = "Data Identical";
}
else
{
// _root.valueofyes2.text = "Data has changed";
}
AmendedRowNumber_array.push(event.itemIndex);
_root.valueofyes1.text = "Pushed";

_root.statementsgrid.addEventListener("cellEdit", cellmodified);
}

Finally once all edits have been completed, the user clicks save.

However there appears to be a problem with the Save Actionscript.

As nothing within the for (i = 0; i < AmendedRowNumber_array.length;i++)
seems to be executing.

on (release)
{
_root.col1row2.text = _root.AccessGroup.results.User_IsTeacher
if (_root.AccessGroup.results.User_IsTeacher == true)
{
var wsSaveStatements_Complete = function ()
{
_root.wsmessage.text = "Examining Results";
if (_root.savestatements.results.Result.Success == true)
{
_root.wsmessage.text = "OK, So lets move on";
_root.wsError.text = "";
}
else
{
_root.wsmessage.text = _root.savestatements.operation + " Error";
_root.wsError.text = _root.savestatements.results.Result.Message
}
};
_root.wsmessage.text = "Setting up CandidateNameCombo";
_root.savestatements.addEventListener("result", wsSaveStatements_Complete);

for (i = 0; i < AmendedRowNumber_array.length;i++)
{
x = AmendedRowNumber_array[i];
// _root.savestatements.params.pStatement.Category_ID = AmendedRowNumber_array[i];
// _root.savestatements.params.pStatement.Comment_ID = AmendedRowNumber_array[i];
// _root.savestatements.params.pStatement.Comment = AmendedRowNumber_array[i];
_root.savestatements.params.pStatement.Subject_ID = 10001;
_root.savestatements.params.pStatement.Category_ID = 1;
_root.savestatements.params.pStatement.Comment_ID = 1;
_root.savestatements.params.pStatement.Comment = "testing Actionscript";
_root.col1row1.text = _root.savestatements.params.pStatement.Subject_ID;
_root.savestatements.trigger();
_root.wsmessage.text = "Called Trigger";
}
_root.valueofyes3.text = x;
// _root.wsmessage.text = "Waiting for SaveStatementsCombo";
}
else
{
_root.wsmessage.text = "Access To Save Denied";
}
}