可手持使新插入的单元格可编辑,而已加载的单元格值为只读



我正在使用handsontable加载值并编辑这些值。

我有一张表格如下:

 var cw = document.getElementById('tableorder').clientWidth;
                        var rest = cw - 550;
                        var container = document.getElementById('tableorder');
                        ordertable = new Handsontable(container, {
                            data: data,
                            colHeaders: ['Collection Mode', 'Remarks','Amount'],
                            columns: [
                                {data: 4, readOnly: false, type: 'autocomplete', source: collectionmethod, validator: collectionmethod_validations, strict: true},
                                {data: 5, readOnly: false},
                                {data: 3, readOnly: false, type: 'numeric', format: '0.000', validator: qty_validations, allowInvalid: true}
                            ],
                            minSpareRows: 1,
                            rowHeaders: true,
                            contextMenu: ['row_above', 'row_below', 'remove_row', 'undo', 'redo'],
                            colWidths: [250, rest, 250],
                            autoWrapRow: true,
                            autoWrapCol: true,
                            beforeRemoveRow: removerow_validation
                        });

我有一组来自ajax的特定值,我正在创建表:

我需要的是:

我需要制作某些细胞read-only。但是,如果我插入另一行,那么包含该特定单元格的新行应该是可编辑的

在我的情况下,我需要以下单元格为read-only

{data: 3, readOnly: false, type: 'numeric', format: '0.000', validator: qty_validations, allowInvalid: true}

我尝试给出readOnly: false,但如果我添加新行,它也将变为只读。

如何将已加载的单元格设为只读单元格,并将新插入的单元格设置为可编辑单元格

得到了解决方案:

cells :function(row, col, prop) {
                                    var cellProperties = {};
                                    if (row < total_length) {
                                        cellProperties.readOnly = true;
                                    }
                                    else
                                    {
                                        cellProperties.readOnly = false;
                                    }
                                        return cellProperties;
                                }

最新更新