Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 仅当页面加载时才可与手机通话的功能_Javascript_Handsontable - Fatal编程技术网

Javascript 仅当页面加载时才可与手机通话的功能

Javascript 仅当页面加载时才可与手机通话的功能,javascript,handsontable,Javascript,Handsontable,我有一个功能,可以将我的手机锁定在handsontable中,但我只想在页面加载时锁定手机 cells:function(row,col,prop){ //Fonctions pour bloquer les cellules var cellProperties = {}; if ([0].indexOf(row) !== -1 && col >= 0)

我有一个功能,可以将我的手机锁定在handsontable中,但我只想在页面加载时锁定手机

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;
                    },
当用户在新行中插入数据时,我不希望新单元格被阻止。所以我考虑一种情况,比如:

如果页面正在加载

但我不知道该怎么做。我不知道道具的效用

有人能帮我吗

编辑:我尝试了几件事:

if (document.readyState === "complete")  {

编辑2:

我的元素的整个初始化:

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;
                    },

这在JavaScript中似乎是一个非常基本的问题。我建议你用谷歌搜索加载事件js,页面加载后Javascript执行,等等


除非您正在寻找一种在handsontable中实现它的特定方法,否则在这种情况下,它可能与它们的挂钩有关。有关详细信息

如果要在加载页面后更改单元格定义,则始终可以使用

hotInstance.updateSettings({
    cells: newCells // where newCells is a new set of conditionals
})
你可以在里面触发这个

$(docuemnt).ready(function(){ // updateSettings });

此应用程序已经存在stackoverflow问题:@JoshSpears我查看了,但它不是同一个应用程序。我不能在handsontable中使用类似的东西:/you使用jquery吗?$docuemnt.readyfunction{//your code here}@JoshSpears它无法工作,因为它是元素初始化中的一个可手持的函数。我为您编辑,以查看我不能使用该事件:/I我已经查看了文档,这就是我问这个问题的原因;
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;
                    },
hotInstance.updateSettings({
    cells: newCells // where newCells is a new set of conditionals
})
$(docuemnt).ready(function(){ // updateSettings });