View Full Version : How to use FormBinding with a ListView?

20 Oct 2009, 1:26 AM
I have a FormPanel with a binding to a Model, like this:

FormPanel formPanel = new FormPanel();
FormBinding binding = new FormBinding(formPanel);

Binding TextFields is working great. Now i want to bind the Drag and Drop List http://www.extjs.com/examples/pages/dnd/listtolist.html to my FormBinding. I only want the ListView on the right side bounded.

Here is my current code:

private ListStore<RoleModelData> storeAssigned = new ListStore<MyModelData>();
private ListStore<RoleModelData> storeAvailable = new ListStore<MyModelData>();

* List available (left side)
ListView<RoleModelData> list1 = new ListView<MyModelData>();
storeAvailable.setStoreSorter(new StoreSorter<MyModelData>());

* List assigned (right side)
ListView<MyModelData> list2 = new ListView<MyModelData>();
storeAssigned.setStoreSorter(new StoreSorter<MyModelData>());

// Here i try to bind it
ListField<MyModelData> lf = new ListField<MyModelData>();
binding.addFieldBinding(new FieldBinding(lf, fieldName));

* Draw Lists
new ListViewDragSource(list1);
new ListViewDragSource(list2);

new ListViewDropTarget(list1);
new ListViewDropTarget(list2);

RowData data = new RowData(.5, 1);
data.setMargins(new Margins(5));

cp.add(list1, data);
cp.add(list2, data);

When i drag and drop items from the left List to the right List, this works, but the FormPanel is not dirty (so i think it did not work). Any hint whats wrong?