# ReportViewer.Toolbar

## Content

# Interface: Toolbar

[ReportViewer](../modules/ReportViewer).Toolbar

Defines the contract for the viewer toolbar.

**`example`**
```ts
const toolbar = {} as Toolbar;
toolbar.getDefaultToolbarItems();
```

## Table of contents

### Methods

- [addItem](ReportViewer.Toolbar#additem)
- [getDefaultToolbarItems](ReportViewer.Toolbar#getdefaulttoolbaritems)
- [removeItem](ReportViewer.Toolbar#removeitem)
- [updateItem](ReportViewer.Toolbar#updateitem)
- [updateLayout](ReportViewer.Toolbar#updatelayout)

## Methods

### <a id="additem" name="additem"></a> addItem

▸ **addItem**<`Item`\>(`item`): `void`

Adds a toolbar item.

**`example`**
```ts
const toolbar = {} as Toolbar;
toolbar.addItem({ key: 'print' } as ToolbarControl);
```

#### Type parameters

| Name | Type |
| :------ | :------ |
| `Item` | extends `Without`<`ToolbarItemButton`, `ToolbarItemDropdown`\> & { `enabled?`: `boolean` ; `icon?`: `Icon` ; `iconCssClass?`: `string` ; `key`: `string` ; `text?`: `string` ; `title?`: `string` ; `action?`: (`curr?`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\> ; `onUpdate?`: (`args`: `ChangedEventArgs`, `curr`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\>  } & { `items`: `DropdownItem`[] ; `selectedKey?`: `string`  } \| `Without`<`ToolbarItemDropdown`, `ToolbarItemButton`\> & { `enabled?`: `boolean` ; `icon?`: `Icon` ; `iconCssClass?`: `string` ; `key`: `string` ; `text?`: `string` ; `title?`: `string` ; `action?`: (`curr?`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\> ; `onUpdate?`: (`args`: `ChangedEventArgs`, `curr`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\>  } & { `checked?`: `boolean`  } = `Without`<`ToolbarItemButton`, `ToolbarItemDropdown`\> & { `enabled?`: `boolean` ; `icon?`: `Icon` ; `iconCssClass?`: `string` ; `key`: `string` ; `text?`: `string` ; `title?`: `string` ; `action?`: (`curr?`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\> ; `onUpdate?`: (`args`: `ChangedEventArgs`, `curr`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\>  } & { `items`: `DropdownItem`[] ; `selectedKey?`: `string`  } \| `Without`<`ToolbarItemDropdown`, `ToolbarItemButton`\> & { `enabled?`: `boolean` ; `icon?`: `Icon` ; `iconCssClass?`: `string` ; `key`: `string` ; `text?`: `string` ; `title?`: `string` ; `action?`: (`curr?`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\> ; `onUpdate?`: (`args`: `ChangedEventArgs`, `curr`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\>  } & { `checked?`: `boolean`  } |

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `item` | `Item` | The toolbar item to add. |

#### Returns

`void`

___

### <a id="getdefaulttoolbaritems" name="getdefaulttoolbaritems"></a> getDefaultToolbarItems

▸ **getDefaultToolbarItems**(`groupName?`): `string`[]

Gets the default toolbar items.

**`example`**
```ts
const toolbar = {} as Toolbar;
const items = toolbar.getDefaultToolbarItems();
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `groupName?` | `string` | The optional group name to filter items. |

#### Returns

`string`[]

The list of toolbar item keys.

___

### <a id="removeitem" name="removeitem"></a> removeItem

▸ **removeItem**(`key`): `void`

Removes a toolbar item.

**`example`**
```ts
const toolbar = {} as Toolbar;
toolbar.removeItem('print');
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `key` | `string` | The toolbar item key. |

#### Returns

`void`

___

### <a id="updateitem" name="updateitem"></a> updateItem

▸ **updateItem**<`Item`\>(`key`, `itemUpdate?`): `void`

Updates a toolbar item.

**`example`**
```ts
const toolbar = {} as Toolbar;
toolbar.updateItem('print', { visible: false });
```

#### Type parameters

| Name | Type |
| :------ | :------ |
| `Item` | extends `Without`<`ToolbarItemButton`, `ToolbarItemDropdown`\> & { `enabled?`: `boolean` ; `icon?`: `Icon` ; `iconCssClass?`: `string` ; `key`: `string` ; `text?`: `string` ; `title?`: `string` ; `action?`: (`curr?`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\> ; `onUpdate?`: (`args`: `ChangedEventArgs`, `curr`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\>  } & { `items`: `DropdownItem`[] ; `selectedKey?`: `string`  } \| `Without`<`ToolbarItemDropdown`, `ToolbarItemButton`\> & { `enabled?`: `boolean` ; `icon?`: `Icon` ; `iconCssClass?`: `string` ; `key`: `string` ; `text?`: `string` ; `title?`: `string` ; `action?`: (`curr?`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\> ; `onUpdate?`: (`args`: `ChangedEventArgs`, `curr`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\>  } & { `checked?`: `boolean`  } = `Without`<`ToolbarItemButton`, `ToolbarItemDropdown`\> & { `enabled?`: `boolean` ; `icon?`: `Icon` ; `iconCssClass?`: `string` ; `key`: `string` ; `text?`: `string` ; `title?`: `string` ; `action?`: (`curr?`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\> ; `onUpdate?`: (`args`: `ChangedEventArgs`, `curr`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\>  } & { `items`: `DropdownItem`[] ; `selectedKey?`: `string`  } \| `Without`<`ToolbarItemDropdown`, `ToolbarItemButton`\> & { `enabled?`: `boolean` ; `icon?`: `Icon` ; `iconCssClass?`: `string` ; `key`: `string` ; `text?`: `string` ; `title?`: `string` ; `action?`: (`curr?`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\> ; `onUpdate?`: (`args`: `ChangedEventArgs`, `curr`: `ToolbarItemBase`<`T`\>) => `void` \| `Partial`<`ToolbarItemBase`<`T`\>\>  } & { `checked?`: `boolean`  } |

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `key` | `string` | The toolbar item key. |
| `itemUpdate?` | `Partial`<`Item`\> | The toolbar item update payload. |

#### Returns

`void`

___

### <a id="updatelayout" name="updatelayout"></a> updateLayout

▸ **updateLayout**(`layout`): `void`

Updates the toolbar layout for different view modes.

**`example`**
```ts
const toolbar = {} as Toolbar;
toolbar.updateLayout({ default: ['print', 'search'] });
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `layout` | [`ToolbarLayout`](../modules/ReportViewer#toolbarlayout) | The layout descriptor for toolbar items. |

#### Returns

`void`
