# JSMenuDatasource

## Overview

`JSMenuDataSource` facilitates interaction with menu-related data by offering methods to manage and retrieve menu datasources and their structures. It supports accessing the `MenuFoundSet`, which represents all menu items in a fully loaded shared foundset, making it readily available for use once requested. This foundset can be used to navigate and interact with the menu data programmatically.

The datasource string of a menu can be retrieved as needed, allowing it to be referenced in various operations. Additionally, `JSMenuDataSource` provides functionality to handle hierarchical menus by enabling access to the relation name that defines parent-to-children relationships. This capability is essential for constructing and navigating nested menu structures effectively.

For more details, refer to the [MenuFoundSet](https://docs.servoy.com/reference/servoycore/dev-api/database-manager/menufoundset) documentation.

## Methods Summarized

| Type                                                                       | Name                                                                  | Summary                                                |
| -------------------------------------------------------------------------- | --------------------------------------------------------------------- | ------------------------------------------------------ |
| [String](/reference/servoycore/dev-api/js-lib/string.md)                   | [getDataSource()](#getdatasource)                                     | Get the datasource string.                             |
| [JSFoundSet](/reference/servoycore/dev-api/database-manager/jsfoundset.md) | [getFoundSet()](#getfoundset)                                         | Returns the MenuFoundSet for this menu datasource.     |
| [String](/reference/servoycore/dev-api/js-lib/string.md)                   | [getParentToChildrenRelationName()](#getparenttochildrenrelationname) | Get relation name that allows to load child menu items |

## Methods Detailed

### getDataSource()

Get the datasource string.

**Returns:** [String](/reference/servoycore/dev-api/js-lib/string.md) String datasource

**Sample**

```js
datasources.menu.mymenu.getDataSource() // returns 'menu:mymenu'
```

### getFoundSet()

Returns the MenuFoundSet for this menu datasource. The menu foundset is always a shared foundset which is fully loaded will all menu items.\
The foundset will be completely created when is first requested.

**Returns:** [JSFoundSet](/reference/servoycore/dev-api/database-manager/jsfoundset.md) A new MenuFoundSet for the datasource.

**Sample**

```js
var fs = datasources.menu.mymenu.getFoundSet()
```

### getParentToChildrenRelationName()

Get relation name that allows to load child menu items

**Returns:** [String](/reference/servoycore/dev-api/js-lib/string.md) String relationName

**Sample**

```js
datasources.menu.mymenu.getParentToChildrenRelationName()
```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/reference/servoycore/dev-api/jsmenudatasource.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
