-
15 Sep 2008 11:32 AM #1
[SOLVED] DataView, ListStore and filters... Question and Bug
[SOLVED] DataView, ListStore and filters... Question and Bug
Hi all,
I have some code that binds a DataView to a ListStore. All works great until I try to use a filter to filter that ListStore. If I bind the ListStore to something else after the filter has been attached, then all is well, however nothing happens to the DataView when the filter is applied.
One other thing I tried was to call the setStore method again after applying the filter. When doing this, there appears to be a bug where the list doesn't get cleared before the new store is applied. For example, if I have a set {a, b, c} and I filter the store to only a, then reapply it with setStore, the ListView will show {a, b, c, a}.
NOTE: I realized that I should be using a DataViewBinder rather than setStore (what is setStore for then???) but I still can't get my list to update when the filter changes, even with the DataViewBinder.
Any help with both of these issues would be greatly appreciated.
-
15 Sep 2008 3:10 PM #2
So I tried using the same code but swapping out the DataView with a Table. Works fine when I do that. That means the problem is definately with the DataView, or the way I'm using it. Here is some code showing how I configure the DataView.
Do I need to do something special with my template?
Code:// In the constructor of a Composite... DockPanel dockPanel = new DockPanel(); final VerticalPanel verticalPanel = new VerticalPanel(); verticalPanel.setSize("100%", "0"); dockPanel.add(verticalPanel, DockPanel.NORTH); dockPanel.setCellHeight(verticalPanel, "0%"); _header = new Text(); _header.setText("Items"); _header.setTagName("h2"); verticalPanel.add(_header); // Create the filter _txtSearchBox = new MyFilterField(); // Just a normal StoreFilterField... _txtSearchBox.setSelectOnFocus(false); _txtSearchBox.setProperty("projectName"); _txtSearchBox.setEmptyText("Search for item..."); _txtSearchBox.setWidth("100%"); verticalPanel.add(_txtSearchBox); _dataView = new DataView(new Template("<div><h3>{name}</h3><div>{summary}</div></div>")); _dataView.setWidth("100%"); _dataView.setHeight("100%"); dockPanel.add(_dataView, DockPanel.CENTER); dockPanel.setCellHeight(_dataView, "100%"); initWidget(dockPanel); // Bind the model to the view, the search box to the list. _listStore = getList(); // Gets a normal ListStore<MyModel> with a few items in it... DataViewBinder<MyModel> binder = new DataViewBinder<MyModel>(_dataView, _listStore); binder.init(); _txtSearchBox.bind(_listStore);
-
15 Sep 2008 3:23 PM #3
Okay... figured it out but this is *very* unintuitive...
I needed to set the itemSelector and then add a class name to my DIV in the template. I did this earlier and it didn't work. It appears that the selector needs to be fully qualified, for example:
<div class="item"></div>
// Works
setItemSelector("div.item");
// Does not work
setItemSelector(".item");


Reply With Quote