useButton
The hook for applying actions against the Qlik engine, commonly attached to a button

Basic Example

The below example returns a function to clear selections in your Qlik application
1
const Button = () => {
2
const { clearSelections } = useButton();
3
4
return (
5
<button onClick={clearSelections}
6
>
7
Clear Selections
8
</button>
9
);
10
};
11
12
export default Button;
Copied!

Button Options

No options can be passed into the hook

Button Properties

The following properties are returned from the hook
  • clearSelections: Function
    • Function to clear all selections
  • previousSelection: Function
    • Function to jump to the previous selection state
  • nextSelection: Function
    • Function to jump to the next selection state
  • select: Function(SearchText<string>, Field<string>)
    • Function to select values in a field
    • Pass a string to search for. Can contain wild cards or numeric search criteria
    • Second parameter is the field you are searching in
  • selectValues: Function(Selections<array>, Field<string>, Toggle<boolean>)
    • Selects some values in a field, by passing an array of values to select
    • The first parameter is an array of values to select, the second is the field
    • Third parameter is whether to toggle selections, defaults to false
    • Selects aan array of strings

Select Values Example

1
const Button = () => {
2
3
const { selectValues } = useButton();
4
5
const sel = ['France', 'Italy']
6
const field = 'country'
7
8
const select = () => (
9
selectValues(sel,field,false)
10
)
11
12
return (
13
<button onClick={select}>
14
Select Values
15
</button>
16
);
17
};
18
19
export default Button;
Copied!
Last modified 1yr ago