Data persistance

With the persistance directive, each change in the data will be sent to a remote URL.



Source code

<html>
<script src="https://jexcel.net/v7/jexcel.js"></script>
<script src="https://jexcel.net/v7/jsuites.js"></script>
<link rel="stylesheet" href="https://jexcel.net/v7/jexcel.css" type="text/css" />
<link rel="stylesheet" href="https://jexcel.net/v7/jsuites.css" type="text/css" />

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

<script>
var mySpreadsheet = jexcel(document.getElementById('spreadsheet'), {
    url:'/jexcel/books.json',
    columns: [
      {
           type: 'autonumber',
           width: '50px',
           title: 'Code',
           name: 'id',
           readOnly: true,
           primaryKey: true
       },
       {
           type: 'text',
           width: '80px',
           title:'Image',
           name:'thumbnailUrl'
       },
       {
           type: 'text',
           width: '200px',
           title:'Title',
           name:'title'
       },
       {
          type: 'text',
           width: '55px',
           title:'Pages',
           name:'pageCount'
       },
       {
           type: 'calendar',
           width: '90px',
           title:'Published',
           name: 'publishedDate'
       },
      {
           type: 'text',
           width: '200px',
           title:'Author',
           name:'authors'
       },
       {
           type: 'dropdown',
           width: '180px',
           title:'Categories',
           name:'categories',
           source:['Internet','Web Development', 'Java', 'Mobile', 'Open Source'],
           multiple:true
      },
    ],
    allowComments:true,
    persistance: '/jexcel/save',
    updateTable: function(instance, cell, col, row, val, label, cellName) {
        if (col == 1) {
             if (! val) {
               cell.innerHTML = '<img src="https://images-na.ssl-images-amazon.com/images/I/21%2Bwfxx2lyL._SX319_BO1,204,203,200_.jpg" style="width:60px;">';
            } else {
                cell.innerHTML = '<img src="' + val + '" style="width:60px;">';
            }
        }

        cell.style.overflow = 'hidden';
    },
    onevent:function() {
        console.log(arguments);
    },
    license: 'YjQzMzdlOTRiOGY3ZTQ0ZDQ4ZTI1YWU3MDFjMDI0ZWJmOTNjODA1NWFiZTRiNDJhNmRiYTJlZjkwODQ3N2IwMWRmNWRjYWUwZDViM2VhMmI3NzVjOTcwMzVlN2ZhODI1Y2EyMmE3NDI0ZmE0ZjVmNGQ2MWEzN2M3MTA4MThhMDUsZXlKdVlXMWxJam9pY0dGMWJDNW9iMlJsYkNJc0ltUmhkR1VpT2pFMk16SXdPVEkwTURBc0ltUnZiV0ZwYmlJNld5SnFjMlpwWkdSc1pTNXVaWFFpTENKcVpYaGpaV3d1Ym1WMElpd2lZMjlrWlhOaGJtUmliM2d1YVc4aUxDSnFjMmhsYkd3dWJtVjBJaXdpTVROemQyMHVZM05pTG1Gd2NDSXNJbXh2WTJGc2FHOXpkQ0pkTENKd2JHRnVJam9pTXlKOQ==',
});
</script>
</html>