ce
ce copied to clipboard
ReadOnly Cell
I love your work.
please help me to Readonly cell I use this (code below) in v3 but doesn't work. $('#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'); } } });
Thanks, please use this one:
<script>
var data2 = [
['BR', 'Cheese', 1, 3.99],
['CA', 'Apples', 0, 1.00],
['US', 'Carrots', 1, 0.90],
['GB', 'Oranges', 0, 1.20],
['CH', 'Chocolats', 1, 0.40],
['AR', 'Apples', 1, 1.10],
['AR', 'Bananas', 1, 0.30],
['BR', 'Oranges', 1, 0.95],
['BR', 'Pears', 1, 0.90],
['', '', '', '=ROUND(SUM(D1:D8), 2)'],
];
var table2 = jexcel(document.getElementById('spreasheet2'), {
data:data2,
columnSorting:false,
columns: [
{ type: 'autocomplete', title:'Country', width:'250', url:'/jexcel/countries' },
{ type: 'autocomplete', title:'Food', width:'150', source:['Apples','Bananas','Carrots','Oranges','Cheese','Kiwi','Chocolats','Pears'] },
{ type: 'checkbox', title:'Stock', width:'100' },
{ type: 'number', title:'Price', width:'100' },
],
updateTable:function(instance, cell, col, row, val, label, cellName) {
if (row == 2 && col == 2) {
cell.classList.add('readonly');
}
}
});
</script>
</html>