码迷,mamicode.com
首页 > 其他好文 > 详细

Handsontable Read-only cells

时间:2015-09-06 12:21:59      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:

一,列只读

技术分享

js代码:

var container1 = document.getElementById(‘example1‘),
  hot1;

hot1 = new Handsontable(container1, {
    data: getCarData(),
    minSpareRows: 1,
    colHeaders: [‘Car‘, ‘Year‘, ‘Chassis color‘, ‘Bumper color‘],
    columns: [
      {
        data: ‘car‘,
        readOnly: true
      },
      {
        data: ‘year‘
      },
      {
        data: ‘chassis‘
      },
      {
        data: ‘bumper‘
      }
    ]
  });

二,单元格 只读 (当前的单元格为‘Nissan‘时只读readOnly)

技术分享

 

var container2 = document.getElementById(‘example2‘),
  hot2;

hot2 = new Handsontable(container2, {
  data: getCarData(),
  minSpareRows: 1,
  colHeaders: [‘Car‘, ‘Year‘, ‘Chassis color‘, ‘Bumper color‘]

});
hot2.updateSettings({
  cells: function (row, col, prop) {
    var cellProperties = {};

    if (hot2.getData()[row][prop] === ‘Nissan‘) {
      cellProperties.readOnly = true;
    }

    return cellProperties;
  }
})

Handsontable Read-only cells

标签:

原文地址:http://www.cnblogs.com/sily-boy/p/4784872.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!