PDA

View Full Version : Getting data out of *To* List in DualListField



JenMandy
16 Jul 2009, 4:02 AM
Please accept my apologies now for my limited knowledge about GXT and GWT. I am as close to a beginner as they come!

Here is my question:
I have a DualListField in a dialog box that pops up when a user would like to filter out columns available on a paginated table. The user moves columns from the "from" list to the "to" list then clicks an "Ok" button. I will then refresh my table to only show the columns the user has selected in the "to" list. I can't seem to access the data in the "to" list.

Here is the code for the DualListField from the dialog web page:
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
setStyleAttribute("margin", "10px");

FormPanel panel = new FormPanel();
panel.setHeading("");

lists = new DualListField();
lists.setFieldLabel("Columns");

from = lists.getFromList();
from.setDisplayField("name");
store = new ListStore();
store.setStoreSorter(new StoreSorter());

store.add(data);
from.setStore(store);

to = lists.getToList();
to.setDisplayField("name");
store = new ListStore();
store.setStoreSorter(new StoreSorter());
to.setStore(store);

panel.add(lists, new FormData("100%"));
panel.setWidth(550);

add(panel);
}

And here is the code I have that is called from the onClick event from my "Ok" button. I try and pull the columns out of the list.

public void update()
{
List storeList = new ArrayList();
storeList = store.getModels();

ArrayList colNames = new ArrayList();
for (int i=0; i<storeList.size(); i++){
colNames.add(storeList.get(i));
}

final KeyValueColumn[] cols = new KeyValueColumn[colNames.size()];
for (int i=0; i<colNames.size(); i++){
cols[i] = new StringKeyValueColumn(
colNames.get(i).toString(),
colNames.get(i).toString());
}

colNamesTable = new KeyValueTable(
null,
"filteredCols",
cols);

}

When I try and get the colNames populated in the KeyValueColumn, I get this string instead: "com.extjs.gxt.ui.client.data.BaseModelData@1e2e566". How can I get the actual text that is moved from the "from" list to the "to" list by the user?
Thanks in advance for any help you can offer me. Again, I apologize for my lack of knowledge about GXT and GWT!
Thanks!
Jennifer