0
votes


I am a junior in Handsontable and i have this problem :
My table is completely working, I use on every cells the editor 'select' with different select options. Depending on the cell, the select options are different. But if I copy/paste the value of a cell to another cell (where this paste value isn't part of the select options), it works, and I would actually like the cell to not validate this value.

I made a little example on JsFiddle to make myself understood :
JsFiddle
If you copy the 'A' on the first row and col, you paste it on a cell of the column C, it works. Even though it shouldn't as the select options of that column are either 'C' or 'D'.

I am pretty sure there is something to do with the cellValidator but I don't know how to proceed. Does anybody have any idea of how to correct this problem..?
Thanks in advance

1

1 Answers

0
votes

What I personnaly use in this case is a 'dropdown' column or 'autocomplete' column. Whit those columns types, you can use the additional option 'strict' that can be true or false, and 'allowInvalid' (again, true or false) :

columns: [
  {
    type: 'dropdown',
    source: ['A', 'B'],
    strict: true,
    allowInvalid: false
  },
  {
    type: 'dropdown',
    source: ['B', 'C', 'D'],
    strict: true,
    allowInvalid: false
  },
  {
    type: 'dropdown',
    source: ['C', 'D'],
    strict: true,
    allowInvalid: false
  }
]

From the documentation :

strict: true - the autocomplete cells will only accept values that are defined in the source array.

[...]

allowInvalid: false - does not allow manual input of value that does not exist in the source. In this case, the ENTER key is ignored and the editor field remains opened.

You can find your example edited here to see how it works.