PDA

View Full Version : Data table serialization


chrischen
05-24-2008, 08:00 PM
I have a table in FLEX that loads data from an XML file. Once the data is loaded the user can drag and drop the rows into a new order.

I currently use this PHP code to take table data serialized by the prototype ajax framework into an array to be inserted into a database. How can I do this in FLEX so that the new order can be sent to a PHP script?


$ranking = 101;
foreach ($_POST['playlist'] as $id) {

$updateSQL = sprintf("UPDATE playlistItems SET `pos`=%s WHERE `id`=%s",
GetSQLValueString($ranking, "int"),
GetSQLValueString($id, "int"));
mysql_select_db($database_list, $list);
$Result1 = mysql_query($updateSQL, $list) or die(mysql_error());
$ranking--;
}

drkstr
06-02-2008, 10:57 PM
There are many aspects to your question. I'm going to assume you already know how to send the data back and forth and just need to know how to modify the data provider.

If it were me, I would try listening to a IndexChangedEvent.HEADER_SHIFT event. In the listener function you could use the properties IndexChangedEvent.oldIndex and IndexChangedEvent.newIndex to modify the data provider directly (parse and update the XML to reflect the new order). From there you can just send the new XML back to your script.


Best Regards,
~Aaron