# readOnlyMode

In Gebra Suite, we have certain types of users like system users those who build the system, users those who will use the system, and admins, they will manage the systems etc. Each user should have different access to the system. It means all access rights should only be given to admin users. Lets suppose we have an orders app and recorded orders. System users should only be allowed to fetch and check orders while on the other hand admins should also be allowed to edit orders and make changes to them. This is this app **readOnlyMode** function comes into play.

## Example

This code sets the whole app to read only mode. All the input controls and even the toolbar button get disabled.

## Parameters

**readOnlyMode** function can be used with or without options. Following are the optional parameters:

1. readOnly - (bool, default = true) This indicates if the readOnly mode is enabled (true) or disabled (false). If it is set to true or without options, it disables the whole app. If set to false, the app starts to behave normally. Every control and each toolbar button is enabled.
2. options - It is a JSON object which can be passed as an additional options.
   * exclude - It is an array of controlIds that should be excluded from the disable functionality of readOnlyMode function.

## Example Usages

We can use this "readOnlyMode" function with or without options. Lets see both of them in action.

### Without options

To disable each and every control and toolbar buttons use this function without any options like

```javascript
app.readOnlyMode(); // This will set app in readOnly Mode.
app.readOnlyMode(true); // This will also set complete app in readOnly Mode.
```

In order to enable all the controls, set the **readOnlyMode** function with false value of readOnly parameter. It will enable back all the controls and the app will start behaving normally.

```javascript
app.readOnlyMode(false); // sets back to normal Mode.
```

### With options

Now if we don't want to use default functionality of disabling or enabling the whole app, we can use **readOnlyMode** options to enable or disable some of the controls. Lets say we want to disable 2 controls from an app then we have to pass the names of these controls in exclude option array like

```javascript
app.readOnlyMode(true, {
  exclude: ["myFrstControl", "mySecondControl"],
});
```

### Example in Action

Lets say we have address app and we want to disable all of it. It can be done in different ways. For a moment, lets stick to "appInitialized" event. Add this function as a custom code of "appInitialized" event and save the app. It will look like this

![Picture of an app in readonly mode](/files/dOdw2DoPenz4hnIIL3Mx)

As we can see each control as well as app toolbar is also disabled.

### Return Values

Function does not explicitly produce return value.


---

# 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://gebra-it.gitbook.io/wiki/client-api-reference/functions/readonlymode.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.
