Open rawandhawez opened 3 years ago
Do you have try with filterOptions ? No disabled, but it's removed
<html>
<script src="https://bossanova.uk/jexcel/v4/jexcel.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jexcel/v4/jexcel.css" type="text/css" />
<script src="https://bossanova.uk/jsuites/v3/jsuites.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jsuites/v3/jsuites.css" type="text/css" />
<div id="spreadsheet2"></div>
<script>
var data2 = [
[3, 'Cheese', true],
[1, 'Apples', true],
[2, 'Carrots', true],
[1, 'Oranges', false],
];
dropdownFilter = function(instance, cell, c, r, source) {
var value = instance.jexcel.getValueFromCoords(c - 1, r);
if (value == 1) {
return ['Apples','Bananas','Oranges'];
} else if (value == 2) {
return ['Carrots'];
} else {
return source;
}
}
jexcel(document.getElementById('spreadsheet2'), {
data:data2,
columns: [
{ type:'dropdown', title:'Category', width:'300', source:[ {'id':'1', 'name':'Fruits'}, {'id':'2', 'name':'Legumes'}, {'id':'3', 'name':'General Food'} ] },
{ type:'dropdown', title:'Food', width:'200', source:['Apples','Bananas','Carrots','Oranges','Cheese'], filter:dropdownFilter },
{ type: 'checkbox', title:'Buy', width:'100' },
],
onchange:function(instance, cell, c, r, value) {
if (c == 0) {
var columnName = jexcel.getColumnNameFromId([c + 1, r]);
instance.jexcel.setValue(columnName, '');
}
}
});
<script>
</html>
Is there a way to disable an item (or multiple items) from being selected in a dropdown list.