useSearch
The hook for searching your data and applying selections
import { useSearch } from "@motor-js/engine"
const Search = () => {
const [options, setOptions] = useState([]);
const [searchValue, setSearchValue] = useState("");
const [qCount, setQCount] = useState(10);
const [qGroupItemCount, setQGroupOptions] = useState(10);
const {
groupResults,
flatResults,
groupselect,
flatSelect,
} = useSearch({
searchValue,
qCount,
qGroupItemCount
})
return (
<div></div>
);
};
The following options can be passed into the hook
searchValue: string
- Required
- The string you are searching your Qlik application for
qCount: number
- Required
- The maximum number of dimensions returned from the search results
qGroupItemCount: number
- Required
- The maximum number of values for each dimension returned from the search results
The following properties are returned from the hook
groupResults: array<groupResult>
- An array of groupedResult objects, containing the search results grouped by dimension
flatResults: array<flatResult>
- An array of flatResult objects, containing a flattened list of the search results. Each dimension value will be returned in a separate object
groupSelect: Function(id)
- A function to apply selections against the Qlik engine
- To be used with
groupResults
- Pass the id returned from the
groupResult
you wish to select. This will be the id of the dimension - Function will select all matching search items for that dimension
flatSelect: Function(dimension<string>, value<string>)
- A function to apply selections against the Qlik engine
- To be used with
flatResults
- Pass the
dimension
andvalue
that you wish to select, both should be astring
The following properties are returned in each instance of the
groupResults
arraydimension: string
- The dimension name returned from the search
value: Array<groupResultItems>
- The an array of dimension values returned from the search
The following properties are returned in each instance of the
groupResultItem
arrayqRanges
- An object containing the character positions matched in the search result
qItem
- The dimension value returned from the search
The following properties are returned in each instance of the
flatResults
arraydimension: string
- The dimension name returned from the search
value: string
- The dimension value returned from the search
Last modified 2yr ago