Spreadsheet

In the following example, the data variable will be automatically updated when the cell value changes.



The following content it would the content of the data variable.


Source code

<html>
<script src="https://jspreadsheet.com/v8/jspreadsheet.js"></script>
<script src="https://jsuites.net/v4/jsuites.js"></script>
<link rel="stylesheet" href="https://jspreadsheet.com/v8/jspreadsheet.css" type="text/css" />
<link rel="stylesheet" href="https://jsuites.net/v4/jsuites.css" type="text/css" />

<div id="spreadsheet"></div>

<textarea id='console'></textarea><br>

<input type='button' value='Get the content of the data variable'
    onclick="document.getElementById('console').value = JSON.stringify(data)">

<script>
var data = [
   {
      "id":1,
      "name":"Jorge",
      "role":"1",
      "parent":0,
      "img":"img/nophoto.jpg",
      "department":1,
      "extension":"3120",
   },
   {
      "id":2,
      "name":"Antonio",
      "role":"2",
      "parent":1,
      "img":"img/nophoto.jpg",
      "department":2,
      "extension":"3121",
   },
   {
      "id":3,
      "name":"Manoel",
      "role":"3",
      "parent":1,
      "img":"img/nophoto.jpg",
      "department":2,
      "extension":"3123",
   },
   {
      "id":4,
      "name":"Pedro",
      "role":"4",
      "parent":3,
      "img":"img/nophoto.jpg",
      "department":2,
      "extension":"3124",
   },
   {
      "id":5,
      "name":"Carlos",
      "role":"4",
      "parent":3,
      "img":"img/nophoto.jpg",
      "department":3,
      "extension":"3125",
   },
   {
      "id":6,
      "name":"Marcos",
      "role":"5",
      "parent":2,
      "img":"img/nophoto.jpg",
      "department":3,
      "extension":"3126",
   },
   {
      "id":7,
      "name":"Ana",
      "role":"6",
      "parent":2,
      "img":"img/nophoto.jpg",
      "department":3,
      "extension":"3127",
   },
   {
      "id":8,
      "name":"Nicolly",
      "role":"7",
      "parent":2,
      "img":"img/nophoto.jpg",
      "department":4,
      "extension":"3128",
   },
   {
      "id":9,
      "name":"Paulo",
      "role":"5",
      "parent":7,
      "img":"img/nophoto.jpg",
      "department":4,
      "extension":"3129",
   },
   {
      "id":10,
      "name":"Iris",
      "role":"5",
      "parent":7,
      "img":"img/nophoto.jpg",
      "department":4,
      "extension":"3130",
   }
]

jspreadsheet(document.getElementById('spreadsheet'), {
    worksheets: [{
        data: data,
        minDimensions: [6, 5],
        worksheetName: 'Employees',
        columnDrag: false,
        columns: [
            {
                title: 'Id',
                type: 'autonumber',
                name: 'id',
                readOnly: true,
                primaryKey: true,
            },
            {
                title: 'Name',
                type: 'text',
                name: 'name',
                width: '140px',
            },
            {
                title: 'Photo',
                type: 'image',
                name: 'img',
                width: '80px',
                render: 'round',
            },
            {
                title: 'Role',
                type: 'record',
                name: 'role',
                width: '180px',
                worksheetId: 'roles',
                worksheetColumn: 1,
            },
            {
                title: 'Department',
                type: 'record',
                name: 'department',
                width: '180px',
                worksheetId: 'departments',
            },
            {
                title: 'Manager',
                type: 'record',
                name: 'parent',
                width: '100px',
                worksheetId: 'employees',
                worksheetColumn: 1,
            },
            {
                title: 'Extension',
                name: 'extension',
                width: '80px'
            },
        ],
    }],
    license: `MWEzMTE4MGFkNWY5YzQzNjE4NjZiNmE1NThhM2M0Yjc1NmUyNGM2N2YzZjU2NDQ5ZjM1MGFiYWNmOTFkNTkwODFiYmYwNDE1YjhhM2ViNGUyMzM2YjYzY2Q4NTcyMWE4MGQ4YjVjNjI2NWY4NWYyMTBjMWU5M2ZmNTU4OGI1MDQsZXlKdVlXMWxJam9pY0dGMWJDNW9iMlJsYkNJc0ltUmhkR1VpT2pFMk5UZzVOakk0TURBc0ltUnZiV0ZwYmlJNld5SnFjM0J5WldGa2MyaGxaWFF1WTI5dElpd2lZM05pTG1Gd2NDSXNJbXB6YUdWc2JDNXVaWFFpTENKc2IyTmhiR2h2YzNRaVhTd2ljR3hoYmlJNklqSWlMQ0p6WTI5d1pTSTZXeUoyTnlJc0luWTRJaXdpY0dGeWMyVnlJaXdpYzJobFpYUnpJaXdpWm05eWJYTWlMQ0p5Wlc1a1pYSWlMQ0ptYjNKdGRXeGhJbDE5`,
});
</script>
</html>