---
title: Add a Modal Editor to the Property Grid
product: Survey Creator
description: Learn how to enhance your survey elements by adding a modal editor to the Property Grid of your fully integrated form builder. This demo demonstrates how to implement a custom property editor that enables survey authors to manage access rules for a selected question within a pop-up dialog. View a free demo example for JavaScript to learn more.
framework: Vue 3
source: https://surveyjs.io/survey-creator/examples/add-modal-property-editor-to-property-grid/vue3js
index: https://surveyjs.io/survey-creator/examples/overview.md
---

# Add a Modal Editor to the Property Grid (Vue 3)

Survey elements come with a variety of built-in properties that cover most use cases. If you want to extend the available functionality, you can [add custom properties](/survey-creator/examples/add-properties-to-property-grid/) to survey elements and [implement custom property editors](/survey-creator/examples/customize-property-editors/). This example demonstrates a custom editor that allows survey authors to configure properties in a pop-up dialog. To open the dialog, click the Set Access Rules button. The dialog features a dynamic table where you can add or remove access rules for the selected question.

Follow the steps below to configure a modal property editor for a custom property:

1. Add a custom property to a question type.            
Call the `addProperty(className, propMeta)` method on the `Serializer` object. `className` is the name of a base or derived class (see the [`getType()`](https://surveyjs.io/form-library/documentation/api-reference/question#getType) method description); `propMeta` is a JSON object with [property settings](https://surveyjs.io/form-library/documentation/customize-question-types/add-custom-properties-to-a-form#survey-element-property-settings).

1. Add an editor for the custom property.           
Register the property editor in the `PropertyGridEditorCollection` and specify a standard JSON object that the custom type should produce. For instance, in this demo, the custom editor is a Dynamic Matrix. 

1. Define a survey JSON schema for the modal dialog.            
The modal dialog is built upon a regular SurveyJS survey. To specify the dialog's content, configure a survey JSON schema and use it to instantiate a [`SurveyModel`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model) object.

1. Add a button that opens the dialog to the editor title.          
Implement an [`onPropertyEditorUpdateTitleActions`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#onPropertyEditorUpdateTitleActions) event handler. Within it, check that the event is raised for a required property and add an [`IAction`](https://surveyjs.io/form-library/documentation/api-reference/iaction) configuration object to the `options.titleActions` array. This configuration object should include the [`action`](https://surveyjs.io/form-library/documentation/api-reference/iaction#action) function.

1. Open the dialog on a button click.         
Call the global `showDialog` method within the `action` function to open the custom dialog when users click the button. Use the method's parameters to specify a `SurveyModel` instance that represents the dialog's content and define handling functions for the Apply and Cancel buttons. When a user clicks Apply, retrieve values from the pop-up survey using its `data` property and assign them to the current question. Refer to the code listing for details.

## Files

### `public/index.html`

```html
<div id="app" style="position: absolute; top: 0; left: 0; right: 0; bottom: 0;"></div>
```

### `src/App.vue`

```html
<template>
    <SurveyCreatorComponent :model="creator" />
</template>
<script setup lang="ts">
    import { SurveyCreatorModel } from "survey-creator-core";
    import { SurveyCreatorComponent } from "survey-creator-vue";
    import { SurveyModel, Serializer, settings } from "survey-core";
    import { PropertyGridEditorCollection, getLocaleStrings } from "survey-creator-core";
    import "survey-core/survey.i18n";
    import "survey-creator-core/survey-creator-core.i18n";
    import "survey-core/survey-core.css";
    import "survey-creator-core/survey-creator-core.css";
    import "./index.css";
    import SurveyTheme from "survey-core/themes";
    import { registerCreatorTheme } from "survey-creator-core";

    registerCreatorTheme(SurveyTheme); // Add predefined Survey Creator UI themes

    // Step 1: Add a custom property to a question type
    Serializer.addProperty("question", {
      name: "accessRules",
      type: "accessrules",
      category: "accessRules",
      showValueInLink: false
    });
    
    // Step 2: Add an editor for the custom property
    PropertyGridEditorCollection.register({
      fit: (prop) => prop.type === "accessrules",
      getJSON: () => {
        return {
          "type": "matrixdynamic",
          "rowCount": 0,
          "allowRemoveRows": false,
          "columns": [
            {
              "name": "userRole",
              "title": "User Role",
              "cellType": "dropdown",
              "readOnly": true,
              "isRequired": true,
              "choices": [
                { "value": "admin", "text": "Admin" },
                { "value": "editor", "text": "Editor" },
                { "value": "viewer", "text": "Viewer" },
                { "value": "guest", "text": "Guest" }
              ]
            },
            {
              "name": "permissions",
              "title": "Permissions",
              "cellType": "dropdown",
              "readOnly": true,
              "choices": [
                { "value": "view", "text": "View" },
                { "value": "edit", "text": "Edit" }
              ],
              "showNoneItem": true,
              "noneText": "No access"
            }
          ]
        }
      }
    });
    
    const translation = getLocaleStrings("en");
    translation.pe.tabs.accessRules = "Access Rules";
    translation.pehelp.accessRules = "Specify user roles that can interact with the selected form element and define their permissions.";
    
    const creator = new SurveyCreatorModel();
    // Step 3: Define a survey JSON schema for the modal dialog
    const popupJson = {
      "elements": [
        {
          "type": "matrixdynamic",
          "name": "accessRules",
          "titleLocation": "hidden",
          "columns": [
            {
              "name": "userRole",
              "title": "User Role",
              "isRequired": true,
              "cellType": "dropdown",
              "isUnique": true,
              "choices": [
                { "value": "admin", "text": "Admin" },
                { "value": "editor", "text": "Editor" },
                { "value": "viewer", "text": "Viewer" },
                { "value": "guest", "text": "Guest" }
              ]
            },
            {
              "name": "permissions",
              "title": "Permissions",
              "cellType": "dropdown",
              "defaultValue": "Edit",
              "choices": [
                { "value": "view", "text": "View" },
                { "value": "edit", "text": "Edit" }
              ],
              "showNoneItem": true,
              "noneText": "No access"
            }
          ],
          "rowCount": 0,
          "maxRowCount": 4,
          "addRowText": "Add Access Rule"
        }
      ],
      "showNavigationButtons": false
    };
    
    const popupSurvey = new SurveyModel(popupJson);
    
    // Step 4: Add a button that opens the dialog to the editor title
    creator.onPropertyEditorUpdateTitleActions.add((_, options) => {
      if (options.property.name === "accessRules") {
        popupSurvey.setValue("accessRules", options.element.accessRules);
        options.titleActions.push({
          id: "setAccessRules",
          title: "Set Access Rules",
          // Step 5: Open the dialog on a button click
          action: () => {
            settings.showDialog({
              componentName: "survey",
              data: { model: popupSurvey },
              onApply: () => {
                const validAccessRules = popupSurvey.validate();
                if (validAccessRules) {
                  // Get values from the pop-up survey using its `data` property
                  // and update the current question (`options.element`)
                  options.element.setPropertyValue("accessRules", popupSurvey.data["accessRules"]);
                  return true;
                }
                return false;
              },
              onCancel: () => {
                console.log("Cancel");
              },
              cssClass: "sv-property-editor",
              title: "Configure Access Rules for " + options.element.title,
              displayMode: "popup"
            }, creator.rootElement)
          }
        });
      }
    });
    
    creator.JSON = {
      "pages": [
        {
          "name": "page1",
          "elements": [
            {
              "type": "text",
              "name": "userName",
              "title": "User Name",
              "accessRules": [
                { "userRole": "admin", "permissions": "edit" },
                { "userRole": "viewer", "permissions": "view" },
                { "userRole": "guest", "permissions": "none" }
              ]
            },
            {
              "type": "text",
              "name": "dob",
              "title": "Date of Birth",
              "maskType": "datetime",
              "maskSettings": {
                "pattern": "m-dd-yyyy"
              }
            }
          ]
        }
      ]
    }
    
    creator.showSidebar = true;
    creator.selectedElement = creator.survey.getQuestionByName("userName");
    creator.expandPropertyGridCategory("accessRules");
</script>
```

### `src/index.css`

```css
.sv-property-editor .sd-root-modern {
    min-width: 640px;
}
```

### `src/main.ts`

```ts
import { createApp } from "vue";
import App from "./App.vue";

const app = createApp(App);
app.mount("#app");
```

### `src/shims-vue.d.ts`

```ts
/* eslint-disable */
declare module "*.vue" {
    import type { DefineComponent } from "vue"
    const component: DefineComponent<{}, {}, any>
    export default component
}
```

### `.eslintrc.js`

```js
module.exports = {
    root: true,
    env: {
        node: true
    },
    extends: [
        "plugin:vue/vue3-essential",
        "eslint:recommended",
        "@vue/typescript/recommended",
        "@vue/prettier",
        "@vue/prettier/@typescript-eslint"
    ],
    parserOptions: {
        ecmaVersion: 2020
    },
    rules: {
        "no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
        "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off"
    },
    overrides: [
        {
            files: [
                "**/__tests__/*.{j,t}s?(x)",
                "**/tests/unit/**/*.spec.{j,t}s?(x)"
            ],
            env: {
                jest: true
            }
        }
    ]
};
```

### `babel.config.js`

```js
module.exports = {
  presets: ["@vue/cli-plugin-babel/preset"]
};
```

### `package.json`

```json
{
  "name": "surveyjs-library-vue3",
  "version": "0.1.0",
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.6.5",
    "tslib": "2.6.1",
    "vue": "^3.4.1",
    "survey-core": "latest",
    "survey-vue3-ui": "latest",
    "survey-creator-core": "latest",
    "survey-creator-vue": "latest",
    "vue-router": "^4.0.0-0",
    "vuex": "^4.0.0-0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^2.33.0",
    "@typescript-eslint/parser": "^2.33.0",
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-plugin-pwa": "~4.5.0",
    "@vue/cli-plugin-router": "~4.5.0",
    "@vue/cli-plugin-typescript": "~4.5.0",
    "@vue/cli-plugin-vuex": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0",
    "@vue/eslint-config-prettier": "^6.0.0",
    "@vue/eslint-config-typescript": "^5.0.2",
    "@vue/test-utils": "^2.0.0-0",
    "eslint": "^6.7.2",
    "eslint-plugin-prettier": "^3.1.3",
    "eslint-plugin-vue": "^7.0.0-0",
    "node-sass": "^4.12.0",
    "prettier": "^1.19.1",
    "sass-loader": "^8.0.2",
    "typescript": "~3.9.3"
  }
}
```

### `tsconfig.json`

```json
{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": [
      "webpack-env",
      "jest"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}
```

## Other Frameworks

- [Angular](https://surveyjs.io/survey-creator/examples/add-modal-property-editor-to-property-grid/angular.md)
- [React](https://surveyjs.io/survey-creator/examples/add-modal-property-editor-to-property-grid/reactjs.md)
- [jQuery](https://surveyjs.io/survey-creator/examples/add-modal-property-editor-to-property-grid/jquery.md)
- [Vanilla JS](https://surveyjs.io/survey-creator/examples/add-modal-property-editor-to-property-grid/vanillajs.md)
