isColumnModificationAllowed

Tags: #<Tag:0x00007f1360597d68>

Hi Handsontable

I find there is a method ‘isColumnModificationAllowed’, which doesn’t allow insert new columns when we have ‘columns’ options in setting. That means we can not set checkbox/dropdown-menu at the same time when we need inserting new column feature.

Is this the handsontable supposed to work?

Or I miss-understand anything here? Any replay here will be helpful, appreciate.

Hi @chens
columns always sets fixed amount of columns in your table. That is why a dropdown menu and a context menu don’t allow to add new columns.

If you would like to add columns anyway you can use an alter method. It can be easily added to a context menu. Here’s https://docs.handsontable.com/pro/1.3.2/demo-context-menu.html a tutorial (at the bottom of the page) how to build a custom context menu.

Thank you very much @aleksandra_budnik

This is really helpful. :smile:

HI @aleksandra_budnik

I can custom the context menu, and use the alter. But when I try to insert a column in the table which has checkbox setting, I will get errors

handsontable.full.js?body=1:6148 Uncaught Error: Cannot create new column. When data source in an object, you can only have as much columns as defined in first data row, data schema or in the 'columns' setting.If you want to be able to add new columns, you have to use array datasource.

Does this mean, in this scenario inserting new columns is forbidden?

Hi @chens
To set a checkbox you have to use columns and settings columns fixes amount of columns that you may have.

To add them in this case you would need to use updateSettings. Here’s an example how to do that: http://jsfiddle.net/6a5dqxa4/