views:

35

answers:

0

Let me briefly describe the problem I'm trying to solve, and see if somebody can provide a better solution than I have.

At the bottom of it, I'm trying to craft a UI that allows the user to select a subset of a set of columns; there is a set of columns M that the user has to choose from, and they can choose 0..m of these. Additionally, some of these chosen columns may be marked up with extra data, such as name changes and type mappings. Lastly, they must be able to choose the order of these selections.

Here's my source data:

[
  {column_name: 'foo'},
  {column_name: 'bar'},
  {column_name: 'baz'}
]

The output data will end up looking something like this for each entry that is included:

{column_name: 'bar', target_name: "Speakeasy", target_type: ginjoint}

I envision this displayed in a datagrid, with the inclusion of a given element indicated by (and controlled by) a checkbox control in one of the columns, and the order of the items in the target list controlled by dragging and dropping in the list itself.

Right now, I have a three-list structure that looks something like this:

  • A source list that contains all of the possible elements.

  • A target list that contains all of the elements whose 'include' meta-field is true (the include property setter adds the element to the target list when set to true, and removes it when set to false)

  • A display list that contains the source list elements wrapped in proxy objects that handle inclusion in the target list when their include attributes are toggled and have the additional metadata on them.

The problem is, changing the order in that display list does not change the order of items in the target list. Moreover, it's not obvious just how the target list ordering should reflect the display list.

This seems like a common enough idiom, however, that somebody must have used it at some point. Even if somebody could provide me with a name or a search term to use to hunt down implementations of this, it'd be fantastic.