I have a function which locks my cells in handsontable but I want to lock them only when the page is loaded.
cells:function(row,col,prop){ //Fonctions pour bloquer les cellules
var cellProperties = {};
if ([0].indexOf(row) !== -1 && col >= 0)
{
cellProperties.readOnly = true;
cellProperties.renderer = firstRowRenderer;
}
if(([0].indexOf(col) == 0) && (data_itk_pro_update[row][0]) && flag==true) //Here is the function to block the first column
{
cellProperties.readOnly = true;
}
if(([1].indexOf(col) == 0) && (data_itk_pro_update[row][1]) && flag==true)
{
cellProperties.readOnly = true;
}
if (readOnlyCellsITKPROU[[row,col]]) {
cellProperties.readOnly = true;
}
return cellProperties;
},
When the user insert data in a new row, I don't want the new cells to be blocked. So I think about a condition like :
If the page is loading
But I don't know how to do. And I don't know the utility of prop
.
Can someone help me please ?
EDIT : I tried several thing :
if (document.readyState === "complete") {
..
$(window).load(function () {
..
window.onload = function () {
..
if(window.onload){
EDIT2 :
The entire initialization of my element :
var container = document.getElementById('tab_itk_pro_modif');
var hotITKPROU = new Handsontable(container, {
data: data_itk_pro_update,
minSpareRows: 1,
fixedRowsTop : 1,
rowHeaders: false,
colHeaders: false,
contextMenu: {
items: {
"remove_row": {
name: 'Supprimer la ligne',
disabled: function () {
return hotITKPROU.getSelected()[0] === 0
}
}
}
},
cells:function(row,col,prop){ //Fonctions pour bloquer les cellules
var cellProperties = {};
if ([0].indexOf(row) !== -1 && col >= 0) //Pour bloquer la première ligne
{
cellProperties.readOnly = true;
cellProperties.renderer = firstRowRenderer;
}
if(([0].indexOf(col) == 0) && (data_itk_pro_update[row][0]) && flag==true)
{
cellProperties.readOnly = true;
}
if(([1].indexOf(col) == 0) && (data_itk_pro_update[row][1]) && flag==true)
{
cellProperties.readOnly = true;
}
if (readOnlyCellsITKPROU[[row,col]]) { //Pour bloquer les composants des id concaténés
cellProperties.readOnly = true;
}
return cellProperties;
},