Search

Search
//<code-header>
fiddle.title = 'Search';
//</code-header>
targetElement.innerHTML = '<p>Type in the field below to search in the grid</p>';
const searchField = new TextField({
    appendTo : targetElement,
    label    : 'Search',
    icon     : 'b-icon b-icon-search',
    value    : 'on',
    style    : 'margin-bottom: 1em',
    onInput  : () => grid.features.search.search(searchField.value)
});

// grid with Search feature
const grid = new Grid({
    appendTo : targetElement,

    // makes grid as high as it needs to be to fit rows
    autoHeight : true,

    features : {
        // enable searching
        search : true
    },

    data : DataGenerator.generateData(5),

    columns : [
        { field : 'name', text : 'Name', flex : 1 },
        { field : 'city', text : 'City', flex : 1 }
    ]
});

// initial search
grid.features.search.search(searchField.value);

Feature that allows the user to search the entire grid. Navigate between hits using the keyboard, [F3] or [Ctrl/CMD + G] moves to next, also pressing [Shift] moves to previous.

Note that this feature does not include a UI, please build your own and call appropriate methods in the feature. For a demo implementation, see Search example.

This feature is disabled by default.

Keyboard shortcuts

This feature has the following default keyboard shortcuts:

Keys Action Action description
F3 goToNextHit Move focus to next search hit
Shift+F3 goToPrevHit Move focus to previous search hit
Ctrl+G goToNextHit Move focus to next search hit
Ctrl+Shift+G goToPrevHit Move focus to previous search hit
Please note that Ctrl is the equivalent to Command and Alt is the equivalent to Option for Mac users

For more information on how to customize keyboard shortcuts, please see our guide

// enable Search
let grid = new Grid({
  features : {
    search : true
  }
});

// perform search
grid.features.search.search('steve');

When Store has lazyLoad, this feature will only work on locally available data

Configs

12

Common

disabledInstancePlugin
listenersEvents

Other

keyMap: Object<String, KeyMapConfig>

See Keyboard shortcuts for details

limit: Number= 1000

The maximum amount of search hits

showHitIndex: Boolean= true

Set to false to not show the search hit index numbers

Misc

clientInstancePlugin
localeClassLocalizable
localizableLocalizable

Properties

17

Common

disabledInstancePlugin

Class hierarchy

isSearch: Boolean= truereadonly
Identifies an object as an instance of Search class, or subclass thereof.
isSearch: Boolean= truereadonlystatic
Identifies an object as an instance of Search class, or subclass thereof.
isEventsEvents
isInstancePluginInstancePlugin
isLocalizableLocalizable

Other

foundCount: Numberreadonly

Number of results found

isHitFocused: Booleanreadonly

Returns true if focused row is a hit

Lifecycle

configBase

Misc

clientInstancePlugin
localeHelperLocalizable
localeManagerLocalizable

Functions

35

Other

Clears search results.

Go to the first hit.

Go to specified hit.

ParameterTypeDescription
indexNumber

Go to the last hit.

Select the next hit, scrolling it into view. Triggered with [f3] or [ctrl]/[cmd] + [g].

Select the previous hit, scrolling it into view. Triggered with [shift] + [f3] or [shift] + [ctrl]/[cmd] + [g].

LstaticLocalizable
onEvents
relayAllEvents
triggerEvents
unEvents

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

doDisableInstancePlugin
initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Events

5
catchAllEvents
destroyEvents
disableInstancePlugin
enableInstancePlugin

Event handlers

5
onDestroyEvents
onDisableInstancePlugin
onEnableInstancePlugin

Typedefs

1