Version: 13.0p
Built: 2025-04-11
 
 
 
 

class SavedSearchItem

 
 
 
SmartClient Enterprise API 13.0p (2025-04-11)
 
 
 
 
 
class SavedSearchItemextends SelectItem

(SSI for short) Provides a UI for creating, editing and applying saved searches for a target using the SavedSearches system.

Normally, a SavedSearchItem is just provided a targetComponent, and all other configuration comes from the central SavedSearches class by default. The targetComponent must be a DataBoundComponent with a DataSource configured.

Searches are applied to the target by calling DataBoundComponent.fetchData(), or, for ListGrids, by calling ListGrid.setViewState(). If SavedSearchItem.saveLastSearch is set, the name of the last search is automatically stored in browser localStorage, and will be applied to the targetComponent as soon as saved searches are loaded.

By default, SavedSearchItem acquires the default DataSource for storing searches and uses it as SelectItem.optionDataSource. The displayed value is the user's name for the search (from SavedSearches.searchNameField) followed by a user-readable summary of the stored search, derived from DataSource.getAdvancedCriteriaDescription(), with a hover to show long values that may be clipped.

If adding searches is allowed, the SavedSearchItem either shows a FormItemIcon (SavedSearchItem.addSearchIcon) or a pickList entry for adding searches (SavedSearchItem.addSearchValue). Either interface opens an EditSearchWindow.

The PickList is automatically configured to show the search name plus the search description (via pickListFields), plus additional columns for icons for editing, removal, copying existing searches, and choosing a default search.

Admin-configured searches are displayed after user-created searches, after a separator.

SavedSearchItem.searchChanged() fires when the user selects a new saved search, saves changes to an existing saved search, or saves a new search. Note that valueField is set to SavedSearches.componentIdField and displayField to SavedSearches.searchNameField.

Saving new searches also causes SavedSearchItem.targetDataSource to be required. You can set SavedSearchItem.newRecordValues to a set of fixed values that should be saved whenever the user saves a new search; this can be used to save searches related to the current user's userId, for example.

The special interface that allows an admin to save shared searches appears if the user has the SavedSearchItem.adminRole as determined by Authentication.hasRole().

Saving full "viewState" for grids

If the targetComponent is a ListGrid or TreeGrid, the default behavior is to store the complete ListGrid.viewState rather that just search criteria. If you want to store just criteria, set SavedSearchItem.storedState to "criteria".

Note: this feature requires SmartClient Pro or better.


  SavedSearchItem instance APIs
  SavedSearchItem class APIs