;
public var contacts1:Object =
{label: "top", children: [
{label: "Acme", status: true, phone: "243-333-5555", children: [
{label: "Sales", status: true, phone: "561-256-5555"},
{label: "Support", status: false, phone: "871-256-5555"}
]},
{label: "Ace", status: true, phone: "444-333-5555", children: [
{label: "Sales", status: true, phone: "232-898-5555"},
{label: "Support", status: false, phone: "977-296-5555"},
]},
{label: "Platinum", status: false, phone: "521-256-5555"}
]};
public function processData(event:ListEvent):void {
// Disable copying data back to the control.
event.preventDefault();
// Get new phone number from editor.
event.currentTarget.editedItemRenderer.data.phone =
MXTIR_MyTreeEditor(event.currentTarget.itemEditorInstance).contactPhone.text;
// Get new status from editor.
event.currentTarget.editedItemRenderer.data.status =
MXTIR_MyTreeEditor(event.currentTarget.itemEditorInstance).confirmed.selected;
// Close the cell editor.
event.currentTarget.destroyItemEditor();
// Notify the list control to update its display.
event.currentTarget.dataProvider.notifyItemUpdate(event.currentTarget.editedItemRenderer);
}
public function processData2(event:ListEvent):void {
// Disable copying data back to the control.
event.preventDefault();
// Get new phone number from editor.
event.currentTarget.editedItemRenderer.data.phone =
TextInput(event.currentTarget.itemEditorInstance).text;
// Get new status from editor.
event.currentTarget.editedItemRenderer.data.status =
TextInput(event.currentTarget.itemEditorInstance).text!="";
// Close the cell editor.
event.currentTarget.destroyItemEditor();
// Notify the list control to update its display.
event.currentTarget.dataProvider.notifyItemUpdate(event.currentTarget.editedItemRenderer);
}
public function processData3(event:ListEvent):void {
// Disable copying data back to the control.
event.preventDefault();
var targetTree:Tree = event.currentTarget as Tree;
trace("####"+targetTree.editedItemRenderer);
// Get label text from editor.
if (targetTree.itemEditorInstance!=null)
{
targetTree.editedItemRenderer.data.label =
TextInput(targetTree.itemEditorInstance).text;
}else
targetTree.editedItemRenderer.data.label="dummy";
// Close the cell editor.
targetTree.destroyItemEditor();
// Notify the list control to update its display.
targetTree..dataProvider.notifyItemUpdate(targetTree.editedItemRenderer);
}
/**
* Process an itemEditEnd event and update the value in the Tree
*/
public function updateTreeValue(event:ListEvent):void {
var targetTree:Tree = event.currentTarget as Tree;
var valueToUpdate:*;
// Disable copying data back to the control.
event.preventDefault();
// Get new data from the editor.
// each custom renderer in this Mustella project that allows editing should expose an updatedValue property
// try getting it here otherwise try text property if maybe its a spark TextInput then fail
try {
valueToUpdate = (targetTree.itemEditorInstance)["updatedValue"];
} catch (e:Error) {
try {
valueToUpdate = (targetTree.itemEditorInstance)["text"];
} catch(e:Error) {
// is some kind of item editor that this Mustella project doesn't support
valueToUpdate = "Error Updating";
}
}
// update the data's value
(targetTree.editedItemRenderer.data)[targetTree.labelField] = valueToUpdate;
// Close the cell editor.
targetTree.destroyItemEditor();
// Notify the list control to update its display.
targetTree.dataProvider.notifyItemUpdate(targetTree.editedItemRenderer);
}
]]>