Frage

I have extended a ListGrid to create a list of saved searches grouped by type of search, whether public or private. This list is populated through a standard SmartGWT datasource.

In addition, I would like to add to this list a grouping of historical searches, that would be available to a user as they create searches on a session-by-session basis (IE. a user creates a new search - until they close the browser, that search will display in the search list, under the grouping 'Historical Searches').

Long story short, I would like to be able to populate the ListGrid from two separate sources - from the already existing datasource and ideally from a RecordList saved in memory. I tried something similar to this:

@Override
public void fetchData() {
    invalidateCache();
    discardAllEdits();
    super.fetchData();
    setCanEdit(true);
    for(Record r : histSearches.toArray()) {
        startEditingNew(r);
        endEditing();
    }
    setCanEdit(false);
    markForRedraw();
};

While this code does get executed, it does not in any way perform the functionality that I'm hoping for it to do. Does anybody have any suggestions on how to perform this functionality? Any help would be greatly appreciated.

War es hilfreich?

Lösung

If you call DataSource.fetchData(), in the callback you can get the selected data as a RecordList. You can then add your per-session searches via recordList.add(), and provide the modified RecordList to a ListGrid via setData().

By the way, there is also an article on the public wiki showing a sample implementation of saved search (though different from what you want):

http://wiki.smartclient.com/display/Main/Saved+Search+%28Smart+GWT%29

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top