Class SavedSearchItem

All Implemented Interfaces:
HasHandlers, HasBlurHandlers, HasChangedHandlers, HasChangeHandlers, HasClickHandlers, HasDataArrivedHandlers, HasDoubleClickHandlers, HasEditorEnterHandlers, HasEditorExitHandlers, HasFocusHandlers, HasIconClickHandlers, HasIconKeyPressHandlers, HasItemHoverHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasKeyUpHandlers, HasPendingStatusChangedHandlers, HasPickerIconClickHandlers, HasShowContextMenuHandlers, HasTitleClickHandlers, HasTitleDoubleClickHandlers, HasTitleHoverHandlers, HasValueHoverHandlers, HasValueIconClickHandlers, PickList

public class SavedSearchItem extends 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 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 (addSearchIcon) or a pickList entry for adding searches (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.

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 targetDataSource to be required. You can set 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 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 storedState to "criteria".

Note: this feature requires Smart GWT Pro or better.

  • Constructor Details

    • SavedSearchItem

      public SavedSearchItem()
    • SavedSearchItem

      public SavedSearchItem(JavaScriptObject jsObj)
    • SavedSearchItem

      public SavedSearchItem(String name)
    • SavedSearchItem

      public SavedSearchItem(String name, String title)
  • Method Details

    • getOrCreateRef

      public static SavedSearchItem getOrCreateRef(JavaScriptObject jsObj)
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, Canvas defaults)
      Changes the defaults for Canvas AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - Canvas defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, FormItem defaults)
      Changes the defaults for FormItem AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - FormItem defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changePickerIconDefaults

      public static void changePickerIconDefaults(FormItemIcon defaults)
    • setAddSearchIcon

      public SavedSearchItem setAddSearchIcon(String addSearchIcon)
      Icon to be used to show the EditSearchWindow.
      Parameters:
      addSearchIcon - New addSearchIcon value. Default value is "[SKINIMG]actions/add.png"
      Returns:
      SavedSearchItem instance, for chaining setter calls
      See Also:
    • getAddSearchIcon

      public String getAddSearchIcon()
      Icon to be used to show the EditSearchWindow.
      Returns:
      Current addSearchIcon value. Default value is "[SKINIMG]actions/add.png"
      See Also:
    • setAddSearchValue

      public SavedSearchItem setAddSearchValue(String addSearchValue)
      Setting this property moves the canAddSearch functionality from an icon next to the form item (addSearchIcon) to the dropdown. When set, the SavedSearchItem will look for this value in specialValues and use it as the trigger action for canAddSearch.
      Parameters:
      addSearchValue - New addSearchValue value. Default value is null
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getAddSearchValue

      public String getAddSearchValue()
      Setting this property moves the canAddSearch functionality from an icon next to the form item (addSearchIcon) to the dropdown. When set, the SavedSearchItem will look for this value in specialValues and use it as the trigger action for canAddSearch.
      Returns:
      Current addSearchValue value. Default value is null
    • setAdminRole

      public SavedSearchItem setAdminRole(String adminRole)
      Role to check for (via Authentication.hasRole() to determine whether admin interfaces are shown. If not explicitly set, at initialization time this will be defaulted to SavedSearches.adminRole.
      Parameters:
      adminRole - New adminRole value. Default value is null
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getAdminRole

      public String getAdminRole()
      Role to check for (via Authentication.hasRole() to determine whether admin interfaces are shown. If not explicitly set, at initialization time this will be defaulted to SavedSearches.adminRole.
      Returns:
      Current adminRole value. Default value is null
    • getAdminSeparatorRecord

      public ListGridRecord getAdminSeparatorRecord()
      Properties for the separator record between locally saved and admin searches.

      This component is an AutoChild named "adminSeparatorRecord". For an overview of how to use and configure AutoChildren, see Using AutoChildren.

      Returns:
      Current adminSeparatorRecord value. Default value is {isSeparator:true}
    • setCanAddSearch

      public SavedSearchItem setCanAddSearch(boolean canAddSearch)
      This flag controls whether adding new searches is allowed.
      Parameters:
      canAddSearch - New canAddSearch value. Default value is false
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getCanAddSearch

      public boolean getCanAddSearch()
      This flag controls whether adding new searches is allowed.
      Returns:
      Current canAddSearch value. Default value is false
    • setCanCopySearch

      public SavedSearchItem setCanCopySearch(Boolean canCopySearch)
      Whether existing searches can be copied.

      If no explicit value is set, it will be defaulted to false if the target is a grid. Searches can be copied by simply selecting them, using the grid's standard UI to edit the search, and then saving that as a new search.

      Parameters:
      canCopySearch - New canCopySearch value. Default value is null
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getCanCopySearch

      public Boolean getCanCopySearch()
      Whether existing searches can be copied.

      If no explicit value is set, it will be defaulted to false if the target is a grid. Searches can be copied by simply selecting them, using the grid's standard UI to edit the search, and then saving that as a new search.

      Returns:
      Current canCopySearch value. Default value is null
    • setCanEditSearch

      public SavedSearchItem setCanEditSearch(Boolean canEditSearch)
      Whether existing searches can be edited.

      If no explicit value is set, it will be defaulted to false if the target is a grid. Searches can be edited by simply selecting them, using the grid's standard UI to edit the search, and then saving that as the original search.

      Parameters:
      canEditSearch - New canEditSearch value. Default value is null
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getCanEditSearch

      public Boolean getCanEditSearch()
      Whether existing searches can be edited.

      If no explicit value is set, it will be defaulted to false if the target is a grid. Searches can be edited by simply selecting them, using the grid's standard UI to edit the search, and then saving that as the original search.

      Returns:
      Current canEditSearch value. Default value is null
    • setCanModifyProperty

      public SavedSearchItem setCanModifyProperty(String canModifyProperty)
      Optional name of a boolean field in the records returned by the optionDataSource, where setting the field to false means the Record cannot be edited or removed by the current user.
      Parameters:
      canModifyProperty - New canModifyProperty value. Default value is null
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getCanModifyProperty

      public String getCanModifyProperty()
      Optional name of a boolean field in the records returned by the optionDataSource, where setting the field to false means the Record cannot be edited or removed by the current user.
      Returns:
      Current canModifyProperty value. Default value is null
    • setCanRemoveSearch

      public SavedSearchItem setCanRemoveSearch(boolean canRemoveSearch)
      Whether existing searches can be removed.
      Parameters:
      canRemoveSearch - New canRemoveSearch value. Default value is true
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getCanRemoveSearch

      public boolean getCanRemoveSearch()
      Whether existing searches can be removed.
      Returns:
      Current canRemoveSearch value. Default value is true
    • setConfirmRemoval

      public SavedSearchItem setConfirmRemoval(boolean confirmRemoval)
      Whether a confirmation message should be shown when a user removes a saved search. The message shown is the confirmRemovalMessage.
      Parameters:
      confirmRemoval - New confirmRemoval value. Default value is true
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getConfirmRemoval

      public boolean getConfirmRemoval()
      Whether a confirmation message should be shown when a user removes a saved search. The message shown is the confirmRemovalMessage.
      Returns:
      Current confirmRemoval value. Default value is true
    • setConfirmRemovalMessage

      public SavedSearchItem setConfirmRemovalMessage(String confirmRemovalMessage)
      Message shown when removal confirmation is enabled and user attempts to remove a saved search. The variable "${title}" is available providing the display name of the saved search.
      Parameters:
      confirmRemovalMessage - New confirmRemovalMessage value. Default value is "Remove saved view '${title}'?"
      Returns:
      SavedSearchItem instance, for chaining setter calls
      See Also:
    • getConfirmRemovalMessage

      public String getConfirmRemovalMessage()
      Message shown when removal confirmation is enabled and user attempts to remove a saved search. The variable "${title}" is available providing the display name of the saved search.
      Returns:
      Current confirmRemovalMessage value. Default value is "Remove saved view '${title}'?"
      See Also:
    • getCopySearchField

      public ListGridField getCopySearchField()
      ListGridField shown in the pickList to allow users to copy existing searches. The field is type "icon" and displays the skin's standard "copy" icon.

      This component is an AutoChild named "copySearchField". For an overview of how to use and configure AutoChildren, see Using AutoChildren.

      Returns:
      Current copySearchField value. Default value is null
    • setCopySearchHoverText

      public SavedSearchItem setCopySearchHoverText(String copySearchHoverText)
      Hover text that appeares over the +{copySearchField}
      Parameters:
      copySearchHoverText - New copySearchHoverText value. Default value is "Copy view"
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getCopySearchHoverText

      public String getCopySearchHoverText()
      Hover text that appeares over the +{copySearchField}
      Returns:
      Current copySearchHoverText value. Default value is "Copy view"
    • setDefaultSearchNameSuffix

      public SavedSearchItem setDefaultSearchNameSuffix(String defaultSearchNameSuffix)
      HTML string to append to the search title in the search name field if this is the default search.
      Parameters:
      defaultSearchNameSuffix - New defaultSearchNameSuffix value. Default value is "<i>[default]</i>"
      Returns:
      SavedSearchItem instance, for chaining setter calls
      See Also:
    • getDefaultSearchNameSuffix

      public String getDefaultSearchNameSuffix()
      HTML string to append to the search title in the search name field if this is the default search.
      Returns:
      Current defaultSearchNameSuffix value. Default value is "<i>[default]</i>"
      See Also:
    • setEditProxyConstructor

      public SavedSearchItem setEditProxyConstructor(String editProxyConstructor)
      Default class used to construct the EditProxy for this component when the component is first placed into edit mode.
      Overrides:
      setEditProxyConstructor in class SelectItem
      Parameters:
      editProxyConstructor - New editProxyConstructor value. Default value is "SavedSearchItemEditProxy"
      Returns:
      SavedSearchItem instance, for chaining setter calls
      See Also:
    • getEditProxyConstructor

      public String getEditProxyConstructor()
      Default class used to construct the EditProxy for this component when the component is first placed into edit mode.
      Overrides:
      getEditProxyConstructor in class SelectItem
      Returns:
      Current editProxyConstructor value. Default value is "SavedSearchItemEditProxy"
      See Also:
    • getEditSearchField

      public ListGridField getEditSearchField()
      ListGridField shown in the pickList to allow users to edit existing searches. The field is type "icon" and displays the skin's standard "edit" icon.

      Does not appear if the target is a grid, since the simplest way of editing a search is just to select it, use the grid's built-in criteria editing to change it, and save as new.

      Specific records can be marked as unable to be edited via canModifyProperty.

      This component is an AutoChild named "editSearchField". For an overview of how to use and configure AutoChildren, see Using AutoChildren.

      Returns:
      Current editSearchField value. Default value is null
    • setEditSearchHoverText

      public SavedSearchItem setEditSearchHoverText(String editSearchHoverText)
      Hover text that appeares over the +{editSearchField}
      Parameters:
      editSearchHoverText - New editSearchHoverText value. Default value is "Save View Configuration"
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getEditSearchHoverText

      public String getEditSearchHoverText()
      Hover text that appeares over the +{editSearchField}
      Returns:
      Current editSearchHoverText value. Default value is "Save View Configuration"
    • getEditSearchWindow

      public EditSearchWindow getEditSearchWindow()
      Modal pop-up window shown when the user adds or edits a search, instance of of EditSearchWindow.

      This component is an AutoChild named "editSearchWindow". For an overview of how to use and configure AutoChildren, see Using AutoChildren.

      Returns:
      Current editSearchWindow value. Default value is null
    • setHint

      public SavedSearchItem setHint(String hint)
      Text shown inside the field that serves as an indicator of what this field is for.
      Overrides:
      setHint in class FormItem
      Parameters:
      hint - New hint value. Default value is "Saved views..."
      Returns:
      SavedSearchItem instance, for chaining setter calls
      See Also:
    • getHint

      public String getHint()
      Text shown inside the field that serves as an indicator of what this field is for.
      Overrides:
      getHint in class FormItem
      Returns:
      Current hint value. Default value is "Saved views..."
      See Also:
    • getMarkAsAdminDefaultField

      public ListGridField getMarkAsAdminDefaultField()
      ListGridField shown in the pickList to allow admin users to designate which field is the admin-default search. The field is type "icon" and displays the skin's standard "checkbox" media.

      This component is an AutoChild named "markAsAdminDefaultField". For an overview of how to use and configure AutoChildren, see Using AutoChildren.

      Returns:
      Current markAsAdminDefaultField value. Default value is null
    • setMarkAsAdminDefaultHoverText

      public SavedSearchItem setMarkAsAdminDefaultHoverText(String markAsAdminDefaultHoverText)
      Hover text that appeares over the +{markAsAdminDefaultField}
      Parameters:
      markAsAdminDefaultHoverText - New markAsAdminDefaultHoverText value. Default value is "Set as default view for all users<br><br><i>[May be overridden by users' own preferences.]</i>"
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getMarkAsAdminDefaultHoverText

      public String getMarkAsAdminDefaultHoverText()
      Hover text that appeares over the +{markAsAdminDefaultField}
      Returns:
      Current markAsAdminDefaultHoverText value. Default value is "Set as default view for all users<br><br><i>[May be overridden by users' own preferences.]</i>"
    • getMarkAsDefaultField

      public ListGridField getMarkAsDefaultField()
      ListGridField shown in the pickList to allow users to designate which field is the default search. The field is type "icon" and displays the skin's standard "checkbox" media.

      This component is an AutoChild named "markAsDefaultField". For an overview of how to use and configure AutoChildren, see Using AutoChildren.

      Returns:
      Current markAsDefaultField value. Default value is null
    • setMarkAsDefaultHoverText

      public SavedSearchItem setMarkAsDefaultHoverText(String markAsDefaultHoverText)
      Hover text that appeares over the +{markAsDefaultField}
      Parameters:
      markAsDefaultHoverText - New markAsDefaultHoverText value. Default value is "Set as default view"
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getMarkAsDefaultHoverText

      public String getMarkAsDefaultHoverText()
      Hover text that appeares over the +{markAsDefaultField}
      Returns:
      Current markAsDefaultHoverText value. Default value is "Set as default view"
    • setNewRecordValues

      public SavedSearchItem setNewRecordValues(Record newRecordValues)
      Additional, fixed Record values that should be used every time a new search is saved.

      This can be used to create user-specific saved searches by adding the userId as part of the saved Record's value.

      Since this property is settable on the fly, you could also add an external interface that would allow a user to save system-wide searches that are not associated with their userId. For example, system-wide searches might have userId set to blank or to a special marker value, and the SelectItem.optionCriteria could be set so that the SavedSearchItem shows system-wide as well as user-specific saved searches.

      Parameters:
      newRecordValues - New newRecordValues value. Default value is null
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getNewRecordValues

      public Record getNewRecordValues()
      Additional, fixed Record values that should be used every time a new search is saved.

      This can be used to create user-specific saved searches by adding the userId as part of the saved Record's value.

      Since this property is settable on the fly, you could also add an external interface that would allow a user to save system-wide searches that are not associated with their userId. For example, system-wide searches might have userId set to blank or to a special marker value, and the SelectItem.optionCriteria could be set so that the SavedSearchItem shows system-wide as well as user-specific saved searches.

      Returns:
      Current newRecordValues value. Default value is null
    • setOfflineStorageKey

      public SavedSearchItem setOfflineStorageKey(String offlineStorageKey)
      Optional key used for local storage of saved searches by this component.

      If unset, the default SavedSearches.offlineStorageKey will be used for local storage instead.

      Has no effect if savedSearchDS is set.

      Parameters:
      offlineStorageKey - New offlineStorageKey value. Default value is null
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getOfflineStorageKey

      public String getOfflineStorageKey()
      Optional key used for local storage of saved searches by this component.

      If unset, the default SavedSearches.offlineStorageKey will be used for local storage instead.

      Has no effect if savedSearchDS is set.

      Returns:
      Current offlineStorageKey value. Default value is null
    • getPickListFields

      public ListGridField[] getPickListFields()
      The SavedSearchItem pickListFields are automatically generated and contain fields for the search name plus the search description, plus additional columns for icons for editing, removal, copying existing searches, and choosing a default search.
      Overrides:
      getPickListFields in class SelectItem
      Returns:
      Current pickListFields value. Default value is [...]
      See Also:
    • getRemoveSearchField

      public ListGridField getRemoveSearchField()
      ListGridField shown in the pickList to allow users to remove existing searches. The field is type "icon" and displays the skin's standard "remove" icon.

      An optional confirmation dialog is shown if confirmRemoval is set.

      By default, if a record is an admin search (because it has no value for SavedSearches.userIdField or because SavedSearches.adminField is true on the record), only an admin will be able to delete it.

      Alternatively, if you are not using the SavedSearchItem's admin features, specific records can be marked as unable to be removed via canModifyProperty.

      This component is an AutoChild named "removeSearchField". For an overview of how to use and configure AutoChildren, see Using AutoChildren.

      Returns:
      Current removeSearchField value. Default value is null
    • setRemoveSearchHoverText

      public SavedSearchItem setRemoveSearchHoverText(String removeSearchHoverText)
      Hover text that appeares over the +{removeSearchField}
      Parameters:
      removeSearchHoverText - New removeSearchHoverText value. Default value is "Remove view"
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getRemoveSearchHoverText

      public String getRemoveSearchHoverText()
      Hover text that appeares over the +{removeSearchField}
      Returns:
      Current removeSearchHoverText value. Default value is "Remove view"
    • setSaveDefaultSearch

      public SavedSearchItem setSaveDefaultSearch(boolean saveDefaultSearch)
      Works identically to ListGrid.saveDefaultSearch. The default is stored in browser localStorage using the savedSearchId of the targetComponent, or a combination of the local or global ID and DataSource ID if no savedSearchId was specified (see documentation for savedSearchId for details).

      If no targetComponent is specified, the savedSearchId or minimal locator of the SavedSearchItem itself will be used.

      Note that if the targetComponent is ListGrid.autoFetchData, and saveDefaultSearch is true, the SavedSearchItem automatically registers with the target component to prevent an automatic fetch with default criteria, and then, after looking up the default search, will perform either the default search or perform a standard autoFetch if no default search is found.

      Parameters:
      saveDefaultSearch - New saveDefaultSearch value. Default value is true
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getSaveDefaultSearch

      public boolean getSaveDefaultSearch()
      Works identically to ListGrid.saveDefaultSearch. The default is stored in browser localStorage using the savedSearchId of the targetComponent, or a combination of the local or global ID and DataSource ID if no savedSearchId was specified (see documentation for savedSearchId for details).

      If no targetComponent is specified, the savedSearchId or minimal locator of the SavedSearchItem itself will be used.

      Note that if the targetComponent is ListGrid.autoFetchData, and saveDefaultSearch is true, the SavedSearchItem automatically registers with the target component to prevent an automatic fetch with default criteria, and then, after looking up the default search, will perform either the default search or perform a standard autoFetch if no default search is found.

      Returns:
      Current saveDefaultSearch value. Default value is true
    • setSavedSearchDS

      public SavedSearchItem setSavedSearchDS(String savedSearchDS)
      Optional override of SavedSearches.defaultDataSource for this SavedSearchItem.
      Parameters:
      savedSearchDS - New savedSearchDS value. Default value is null
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getSavedSearchDS

      public String getSavedSearchDS()
      Optional override of SavedSearches.defaultDataSource for this SavedSearchItem.
      Returns:
      Current savedSearchDS value. Default value is null
    • setSavedSearchId

      public SavedSearchItem setSavedSearchId(String savedSearchId)
      Optional explicit identifier for saved searches. See saveDefaultSearch for details.

      Note : This is an advanced setting

      Parameters:
      savedSearchId - New savedSearchId value. Default value is null
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getSavedSearchId

      public String getSavedSearchId()
      Optional explicit identifier for saved searches. See saveDefaultSearch for details.
      Returns:
      Current savedSearchId value. Default value is null
    • setSaveLastSearch

      public SavedSearchItem setSaveLastSearch(boolean saveLastSearch)
      If 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.
      Parameters:
      saveLastSearch - New saveLastSearch value. Default value is false
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getSaveLastSearch

      public boolean getSaveLastSearch()
      If 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.
      Returns:
      Current saveLastSearch value. Default value is false
    • setStoredState

      public SavedSearchItem setStoredState(SavedSearchStoredState storedState)
      Set to "criteria" if you want only criteria to be stored for ListGrids and TreeGrids instead of the full viewState of the component.
      Parameters:
      storedState - New storedState value. Default value is null
      Returns:
      SavedSearchItem instance, for chaining setter calls
      See Also:
    • getStoredState

      public SavedSearchStoredState getStoredState()
      Set to "criteria" if you want only criteria to be stored for ListGrids and TreeGrids instead of the full viewState of the component.
      Returns:
      Current storedState value. Default value is null
      See Also:
    • setTargetComponent

      public SavedSearchItem setTargetComponent(DataBoundComponent targetComponent)
      Component that saved searches should apply to. When set, whenever searchChanged() fires, the search is automatically applied to the targetComponent unless the searchChanged event is cancelled.

      To avoid leaking local storage, saving searches will not be allowed for the target grid unless it specifies savedSearchId, or an explicit local or global ID is present.

      If this method is called after the component has been drawn/initialized: Changes the targetComponent to the passed in newTargetComponent.

      Parameters:
      targetComponent - the newTargetComponent. Default value is null
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getTargetComponent

      public DataBoundComponent getTargetComponent()
      Component that saved searches should apply to. When set, whenever searchChanged() fires, the search is automatically applied to the targetComponent unless the searchChanged event is cancelled.

      To avoid leaking local storage, saving searches will not be allowed for the target grid unless it specifies savedSearchId, or an explicit local or global ID is present.

      Returns:
      Current targetComponent value. Default value is null
    • setTargetDataSource

      public SavedSearchItem setTargetDataSource(DataSource targetDataSource)
      DataSource that the saved searches are performed against.

      Normally auto-derived from targetComponent.dataSource, but can be specified manually if no targetComponent is provided. In this case, searchChanged() would be implement to apply criteria in a custom way.

      Parameters:
      targetDataSource - New targetDataSource value. Default value is null
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getTargetDataSource

      public DataSource getTargetDataSource()
      DataSource that the saved searches are performed against.

      Normally auto-derived from targetComponent.dataSource, but can be specified manually if no targetComponent is provided. In this case, searchChanged() would be implement to apply criteria in a custom way.

      Returns:
      Current targetDataSource value. Default value is null
    • setTargetEditsCriteria

      public SavedSearchItem setTargetEditsCriteria(Boolean targetEditsCriteria)
      Whether the targetComponent has built-in criteria editing or does not. True by default if the target is a ListGrid or TreeGrid (but not CubeGrid).

      When the target has built-in criteria editing, the SavedSearchItem does not try to provide a FilterBuilder-based criteria editing interface, so the SavedSearchEditor is simplified to just allow naming of searches.

      Parameters:
      targetEditsCriteria - New targetEditsCriteria value. Default value is null
      Returns:
      SavedSearchItem instance, for chaining setter calls
    • getTargetEditsCriteria

      public Boolean getTargetEditsCriteria()
      Whether the targetComponent has built-in criteria editing or does not. True by default if the target is a ListGrid or TreeGrid (but not CubeGrid).

      When the target has built-in criteria editing, the SavedSearchItem does not try to provide a FilterBuilder-based criteria editing interface, so the SavedSearchEditor is simplified to just allow naming of searches.

      Returns:
      Current targetEditsCriteria value. Default value is null
    • setTitle

      public SavedSearchItem setTitle(String title)
      Title of this FormItem. Mote that the title is hidden by default for SavedSearchItem.
      Overrides:
      setTitle in class FormItem
      Parameters:
      title - New title value. Default value is "Views"
      Returns:
      SavedSearchItem instance, for chaining setter calls
      See Also:
    • getTitle

      public String getTitle()
      Title of this FormItem. Mote that the title is hidden by default for SavedSearchItem.
      Overrides:
      getTitle in class FormItem
      Returns:
      Current title value. Default value is "Views"
      See Also:
    • searchChanged

      public boolean searchChanged(Criteria newCriteria, Record searchData)
      Event fired whenever a user changes the currently selected saved search, modifies a saved search or adds a new saved search.

      If a targetComponent has been specified, searchChanged automatically applies the new search to the targetComponent unless the event is cancelled .

      Parameters:
      newCriteria - new criteria
      searchData - savedSearch record
      Returns:
      whether to automatically apply the search to the targetComponent
    • setDefaultProperties

      public static void setDefaultProperties(SavedSearchItem savedSearchItemProperties)
      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties of the class instance passed to this function. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.

      Parameters:
      savedSearchItemProperties - properties that should be used as new defaults when instances of this class are created
      See Also: