views:

741

answers:

0

Hi,

On the flex side i have a tree component which gets his Tree data from the backend. On the backend side we have Django using Pyamf for communication with Flex.

We use MPTT (Modified Preorder Tree Traversal) Dango app to store Categories in a tree like fashion (a category Class has a parent field). We also have an Item Model Class which takes a category id as FK, item takes the leaf role.

If i want to build a tree of all items belonging to me how would you approach such a task.

  • Create an XML string and send it back as the dataprovider for the tree Flex component.

  • Send my items and a subset of all categories used in myitems to the Flex application which will then create the ArrayCollection or XML for the Tree ?

In the First case how can i rebuild a valid Tree structure having children items and categories.

Given an item i can check his parent while parent != null i add the category name to a stack then go thought the stack to creates nodes one by one if they do not exists.

How would you store/generate such data ? I am ready to loose some flexibility for simplicity.

Thanks,