Disable delete button for particular coloumn HandsonTable

Tags: #<Tag:0x00007efc719bad10>

Hi @aleksandra_budnik

Unable to disable the delete button for a particular column please can you help me with this.
Thank you

Hi @sumanthhs48

Without the code demo from your side I won’t be able to suggest much. Can you please prepare one showing your issue?

document.addEventListener("DOMContentLoaded", function() {

function getCarData() {
return [
{car: “Mercedes A 160”, year: 2011, price_usd: 7000, price_eur: 7000},
{car: “Citroen C4 Coupe”, year: 2012, price_usd: 8330, price_eur: 8330},
{car: “Audi A4 Avant”, year: 2013, price_usd: 33900, price_eur: 33900},
{car: “Opel Astra”, year: 2014, price_usd: 5000, price_eur: 5000},
{car: “BMW 320i Coupe”, year: 2015, price_usd: 30500, price_eur: 30500}
];
}

var
container = document.getElementById(‘example1’),
hot;

hot = new Handsontable(container, {
data: getCarData(),
/* editor: false,
*/ colHeaders: [‘Car’, ‘Year’, ‘Price ($)’, ‘Price (€)’],
beforeKeyDown: function(e){
if(e.key === ‘Delete’ || e.key === ‘Backspace’){
event.stopImmediatePropagation();
}
}
});

});

i need that beforeKeyDown to work only on particular column

Hi @sumanthhs48

Thank you for the code. What you can do here is to use getSelected() method to specify the rows or columns and set your function to that range:

https://jsfiddle.net/aszymanski/j6nw4hyc/1/

Here’s an explanation about the getSelected() method: https://handsontable.com/docs/api/core/#getselected