RemoveColumn Grayed out in Context Menu

Tags: #<Tag:0x00007f136854cf68>

The option to remove column in the context menu is grayed out. What would cause this?
Version 1.9.1

var dataObject = Model.getJSMetaData;  
var hotElement = document.querySelector('#hot');
var hotElementContainer = hotElement.parentNode;
var hotSettings = {
    data: dataObject,
    columns: [
 {
     data: 'AssetId',
     type: 'numeric',
     width: 60
 },
 {
     data: 'Platform',
     type: 'numeric',
 },
{
    data: 'AnotherField',
    type: 'text'
}
    ],
    colHeaders: [ 'AssetId','Platform','AnotherField'],
    columnSorting: {
        column: 0
    },
    sortIndicator: true,
    stretchH: 'all',
    width: '100%',
    autoWrapRow: true,
    height: '100%',
    contextMenu: true,
    minSpareRows: 0,
    allowInsertRow: false,
    allowInsertColumn: false,
    //maxRows: 22,
    rowHeaders: true,
    wordWrap:false,
    dropdownMenu: true,
    filters: true,
    allowRemoveColumn: true,
    manualColumnResize: true,
    manualRowResize: true,
    readOnly: true,
    multiSelect: false,
    columnSorting: true,
    manualColumnMove: true,
    afterOnCellMouseDown: itemSelected
};

var hot = new Handsontable(hotElement, hotSettings);

Hi @mmoles

I’ve uploaded your code into a JSFiddle to be able to check it faster: http://jsfiddle.net/handsoncode/v4j6pcr9/

I’ve replaced the data source dataObject (and commented it from columns settings) as I do not have an access to Model.getJSMetaData;.

So… when it comes to the greyed out remove column option it happens cause you have added the fixed amount of columns via columns options. Here’s a demo where you can test it: http://jsfiddle.net/handsoncode/3mw4pL4j/

ps. please notice that Handsontable doesn’t support %values, so I have also commented the

width: ‘100%’,
height: ‘100%’,

1 Like

This was the data object. I also noticed i had Platform as the wrong type. I used your first example and swapped a small subset of data and still had the same issue.

var dataObject = [
    {
    	"AssetId": 11134,
    	"Platform": "New",
    	"AnotherField": "RandomVal1",
    },
    {
    	"AssetId": 11135,
    	"Platform": "New",
    	"AnotherField": "RandomVal2",
    },
    {
    	"AssetId": 11136,
    	"Platform": "New",
    	"AnotherField": "RandomVal3",
    },
    {
    	"AssetId": 11137,
    	"Platform": "New",
    	"AnotherField": "RandomVal4",	
    }
];

OK, so then this is the demo: http://jsfiddle.net/handsoncode/nxrL1end/

Currently, when you have an object data you cannot remove or add columns to the dataset (simplified example http://jsfiddle.net/handsoncode/ymgpv3fw/). You would need to update the columns settings.

Here is how you can add a custom option to the context menu: http://jsfiddle.net/handsoncode/7r3Lgvtf/

To get an active column you can call getSelected() method and use the 2nd parameter.