Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Default criteria for listgrid

    I'm using smartgwt 2.2. I have several DMI datasources configured, using xml configuration.

    I have datasources "item" and "history". Each has a Long "id" as its primary key. history records have a reference to an item (field "item", type "integer").

    I have two ListGrids on a page. The first (itemGrid) uses the item datasource and works fine.

    The second (historyGrid) uses the history datasource. When the user selects an item, the historyGrid is updated to show the history records for that item, via a selectionChangedHandler that calls (roughly):

    Code:
      Integer itemId = event.getSelectedRecord().getAttributeAsInt("id");
      Criteria criteria = new Criterion("item", OperatorId.EQUALS, itemId);
      hisroryGrid.setCriteria(criteria); //this doesn't seem to do anything.
      historyGrid.fetchData(criteria);
    This works fine, however, I also want the user to be able to filter the history results. If I call historyGrid.setShowFilterEditor(true), I can filter the results, but it loses the filter I manually added above when the item was selected, and returns ALL history records that match the criteria in the filter editor, not just those for the selected item type.

    If I instead use a FilterBuilder, then I can get what I want; in the clickHandler for the button that applies the FilterBuilder to the listgrid, I can create a criteria that is (my criteria) AND (filterbuilder criteria), then call historyGrid.fetchData with the new criteria.

    This works, but I don't want to use a filter builder; it's less inuitive and less user-friendly than the filtereditor row.

    I've tried overridding the various fetchData and filterData methods in the historyGrid; none of these are called when the filtereditor is updated.

    I can't find any way to control what happens when the user clicks on the filter button on the filtereditor bar (or presses enter, or whatever).

    Is there a way to do this? I thought I'd be able to do something like override filterChanged(), or add a filterChangedHandler, or something, but I can't find anything.

    Am I stuck with a FilterBuilder?

    Cheers.

    #2
    In 2.2, you need to merge the criteria to prevent them being dropped. In 2.4, there's automatic smart merging that takes place.

    Comment


      #3
      Ok, I'll upgrade and see.

      Thanks for the quick response.


      Edit: That worked a treat, thanks.
      Last edited by hopey_dishwasher; 4 Mar 2011, 12:28.

      Comment

      Working...
      X