---
title: Matrix Table with Custom Cell Types
product: Form Library
description: Learn how to expand the built-in list of available input types of a matrix table. This demo for JavaScript illustrates how to add a File upload as a custom input field within an individual matrix cell.
framework: React
source: https://surveyjs.io/form-library/examples/change-cell-input-type-in-matrix-table/reactjs
index: https://surveyjs.io/form-library/examples/overview.md
---

# Matrix Table with Custom Cell Types (React)

Multi-Select Matrix and Dynamic Matrix questions allow respondents to answer questions within matrix cells using a number of built-in editors. This example shows how you can extend the number of available cell editors by using other editors from SurveyJS Form Library or by implementing a custom editor.

By default, Multi-Select Matrix and Dynamic Matrix columns support the cell editors listed in the [`cellType`](https://surveyjs.io/form-library/documentation/api-reference/multi-select-matrix-column-values#cellType) property description. These cell editors are based upon standalone question types from SurveyJS Form Library. However, the library also includes other question types. To use them as matrix cell editors, add a property named as the question type to the [`matrixDropdownColumnTypes`](https://github.com/surveyjs/survey-library/blob/241175c388587c36aed2c33a68b25f0a87cf663b/src/question_matrixdropdowncolumn.ts#L63) object and assign an empty object to this property. The following code shows how to add the [File Upload](https://surveyjs.io/form-library/documentation/api-reference/file-model) question type to the list of supported cell editors:

```js
import { matrixDropdownColumnTypes } from "survey-core";

matrixDropdownColumnTypes["file"] = {};
```

Now, you can create a File Upload matrix column by setting its `cellType` property to `"file"` in the survey JSON schema. To configure the column, you can use the properties of the standalone question type. For instance, this demo enables the [`allowMultiple`](https://surveyjs.io/form-library/documentation/api-reference/file-model#allowMultiple) property for the File Upload column (see the `survey.json` file).

> The same instructions apply if you want to use a [custom question type](https://surveyjs.io/form-library/documentation/customize-question-types/create-specialized-question-types) as a matrix cell editor.

## Files

### `public/index.html`

```html
<div id="surveyElement" style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; min-height: 100%; height:100%"></div>
```

### `src/SurveyComponent.jsx`

```js
import React from "react";
import { Model } from "survey-core";
import { Survey } from "survey-react-ui";
import "survey-core/survey-core.min.css";
import "./index.css";
import { json } from "./json";
import { matrixDropdownColumnTypes } from "survey-core";

// Enable the File Upload type for use in matrix columns
matrixDropdownColumnTypes["file"] = {};

function SurveyComponent() {
    const survey = new Model(json);
    survey.onComplete.add((sender, options) => {
        console.log(JSON.stringify(sender.data, null, 3));
    });
    return (<Survey model={survey} />);
}

export default SurveyComponent;
```

### `src/index.css`

```css
/* You can add your custom CSS here. */
```

### `src/index.js`

```js
import React from "react";
import { createRoot } from "react-dom/client";
import SurveyComponent from "./SurveyComponent";

const root = createRoot(document.getElementById("surveyElement"));
root.render(<SurveyComponent />);
```

### `src/json.js`

```js
export const json = {
  "elements": [
    {
      "name": "first-name",
      "title": "First name:",
      "type": "text",
      "titleLocation": "left",
      "isRequired": true
    },
    {
      "name": "last-name",
      "title": "Last name:",
      "type": "text",
      "isRequired": true,
      "titleLocation": "left",
      "startWithNewLine": false
    },
    {
      "name": "email",
      "title": "E-mail:",
      "type": "text",
      "inputType": "email",
      "isRequired": true,
      "titleLocation": "left",
      "startWithNewLine": false
    },
    {
      "type": "matrixdynamic",
      "name": "assignments",
      "title": "Submit your assignments",
      "addRowText": "Add a subject",
      "columns": [
        {
          "name": "subjects",
          "title": "Select a subject",
          "cellType": "dropdown",
          "isRequired": true,
          "choices": [ "English: American Literature", "English: British and World Literature", "Math: Consumer Math", "Math: Practical Math", "Math: Developmental Algebra", "Math: Continuing Algebra", "Math: Pre-Algebra", "Math: Algebra", "Math: Geometry", "Math: Integrated Mathematics", "Science: Physical Science", "Science: Earth Science", "Science: Biology", "Science: Chemistry", "History: World History", "History: Modern World Studies", "History: U.S. History", "History: Modern U.S. History", "Social Sciences: U.S. Government and Politics", "Social Sciences: U.S. and Global Economics", "World Languages: Spanish", "World Languages: French", "World Languages: German", "World Languages: Latin", "World Languages: Chinese", "World Languages: Japanese" ]
        },
        {
          "name": "assignment-scans",
          "title": "Upload your assignment",
          "cellType": "file",
          "isRequired": true,
          "allowMultiple": true
        },
        {
          "name": "notes",
          "title": "Additional comments",
          "cellType": "comment"
        }
      ],
      "rowCount": 1
    }
  ],
  "completeText": "Submit"
};
```

### `src/theme.js`

```js
export const themeJson = {};
```

### `package.json`

```json
{
  "dependencies": {
    "react": "latest",
    "react-dom": "latest",
    "survey-core": "latest",
    "survey-react-ui": "latest"
  },
  "devDependencies": {
    "react-scripts": "latest"
  }
}
```

## Other Frameworks

- [Angular](https://surveyjs.io/form-library/examples/change-cell-input-type-in-matrix-table/angular.md)
- [Vue 3](https://surveyjs.io/form-library/examples/change-cell-input-type-in-matrix-table/vue3js.md)
- [jQuery](https://surveyjs.io/form-library/examples/change-cell-input-type-in-matrix-table/jquery.md)
- [Vanilla JS](https://surveyjs.io/form-library/examples/change-cell-input-type-in-matrix-table/vanillajs.md)
