jExcel Spreadsheet - readOnly options

Different options for readonly.

by Spreadsheet Online

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://www.bossanova.uk/components/bossanova-ui/css/jquery.jexcel.css">
<script src="https://www.bossanova.uk/components/bossanova-ui/js/jquery.jexcel.js"></script>

<div id="my"></div>

JavaScript

data = [
    ['Mazda', 2001, 2000, '2006-01-01'],
    ['Pegeout', 2010, 5000, '2005-01-01'],
    ['Honda Fit', 2009, 3000, '2004-01-01'],
    ['Honda CRV', 2010, 6000, '2003-01-01'],
];

// Readonly first column
$('#my').jexcel({
    data:data,
    colHeaders: ['Model', 'Date', 'Price', 'Date'],
    colWidths: [ 300, 80, 100, 100 ],
    columns: [
        { type: 'text', readOnly:true },
        { type: 'numeric' },
        { type: 'numeric' },
        { type: 'text' },
    ]
});

// Set readonly a specific column
$('#my').jexcel('updateSettings', {
    cells: function (cell, col, row) {
        // If the column is number 4 or 5
        if (row == 2 && col == 2) {
            $(cell).addClass('readonly');
        }
    }
});