Vincent Zhou
Vincent Zhou

Reputation: 503

handsontable: how to use the prop in the cell

I like to use the use handsontable cells to highlights the changed value (https://github.com/warpech/jquery-handsontable)

cells   function(row, col, prop)    Defines the cell properties for given row, col, prop coordinates

The change happened is in another function and the row sequence is changed too. So I cannot easily to tag the changed cell by row,col. So I think my only choice is the third parameter (“prop”). But prop is means property? and how I can assign independent and customized property for each cell? Sample code is appreciated. thanks

Upvotes: 0

Views: 4503

Answers (1)

PostureOfLearning
PostureOfLearning

Reputation: 3541

The "cells" option is used for constructor or column options.

Here is an example of how it can be used:

$('div#example1').handsontable({
  cells: function (row, col, prop) {
    var cellProperties = {}
    if(row === 0 && col === 0) {
      cellProperties.readOnly = true;
    }
    return cellProperties;
  }
})

If you want to make changes to changed cells, then I suggest having a look at "afterChange":

$('div#example1').handsontable({
  afterChange: function (changes, source) {
    if (source=== 'loadData') {
        return; //don't do anything as this is called when table is loaded
    }
    var rowIndex = changes[0];
    var col = changes[1];
    var oldCellValue = changes[2];
    var newCellValue = changes[3];
    // apply your changes...
  }
})

I hope this helps...

Upvotes: 1

Related Questions