Dynamic Merge Specific to Column number

Hello I am new to HandsOnTable , I need help on that how I can achieve dynamic merge?

Scenario: User will click on insert row command from context menu.Then immediately according to where user clicks on a column I need to merge cells so I am having multiple columns for example user clicks on 2nd row then I need to merge only 1 cell before to that with the above row and for 7 th column I need to merge 4 cells like that.

I visited call back functions there I selected the event afterOnCellContextMenu then I am getting the output in the log where i clicked on table but I couldn’t understand the logic what they written,

So please help me on this

Hi @kunisettichandra

if you need to know the coordinates of the cell for which the menu has been opened you can use getSelectedLast() - it returns indexes of rows and columns for start and end coordinates.

Then you can call updateSettings to merge the cells.

Hi @aleksandra_budnik

I wrote like this

import React from ‘react’;
import ReactDOM from ‘react-dom’;
import { HotTable } from ‘@handsontable-pro/react’;
import Handsontable from ‘handsontable-pro’;

class App extends React.Component {
constructor(props) {
super(props);
this.hotSettings = {
data: Handsontable.helper.createSpreadsheetData(5, 5),
colHeaders: true,
contextMenu: {
items: {
‘row_above’: {
name: ‘Insert row above this one (custom name)’
},
‘row_below’: {},
‘merge_cells’:{
name:‘merge’,
},
‘separator’: Handsontable.plugins.ContextMenu.SEPARATOR,
‘clear_custom’: {
name: ‘Clear all cells (custom)’,
callback: function() {
this.clear();
}
}
}
}
};
}

getSelectedLast()
{
alert(“hi”);
}
render() {
return (




);
}
}

ReactDOM.render(, document.getElementById(‘example1’));

but it is not workiing can you suggest me how make it work: slight_smile:

Here is a sample code that should help https://codepen.io/anon/pen/rqZvVa?editors=0010

Instead of using react js can’t we get the column number by using (Call Backs)afterOnCellContextMenu ?

if possible please give me an example how to use it?

Yes, you can use the hook. Here is an example https://jsfiddle.net/9by1jw8z/

Hi @aleksandra_budnik,

I used the code what you have suggested but I am getting

“Evaluation version of Handsontable pro.
Not licensed for production use”

To avoid this I tried licenseKey:‘00000-*’ but not worked at all.

so ,suggest me what to do now?

The license key is given after purchasing a license of Handsontable Pro. When you purchase it you get a new my.handsontable.com account and there in the SETUP tab (but also on the email) you get a string that is yours (and only your) key to be put into the instance initialization settings.

thanks @aleksandra_budnik I will be back

You’re welcome.

Feel free to send me an email at support@handsontable.com with any questions regarding PRO installation.