Hi,
I have 2 different types of settings for my handsontable,
- ViewMode in which I do not have any validation in any of my column,
- EditMode in which I have specific validations for specific columns.
My problem is how do I switch between those two settings when the user clicks edit button?
Hi @rakshith.gowdavr
Without a demo, can be hard to find a solution.
So please create a JS playground demo (JSFiddle, CodePen, StackBlitz).
Controller file:
settings = {
'view': {
columns: [
{ data: col1 },
{ data: col2 }
],
readOnly: true
},
'validate': {
{ data: col1, validator: this.envelopesColumn1Validator },
{ data: col2, validator: this.envelopesColumn2Validator }
],
readOnly: false,
beforeValidate: function (value, row, prop, source) {
return { "value": value, "row": row, "loadType": this.getData()[0] }
},
}
HTML part:
<hot-table [hotId]="hotTableId" [data] = "envData"
[settings] = "settings[dataMode]"
</hot-table>
So as and when I need to enable and disable validations, I update the value of dataMode variable to either ‘view’ or ‘validate’, but the validations are not running as expected.
Hey @rakshith.gowdavr
usually the
My problem is how do I switch between those two settings when the user clicks edit button?
the switch can be done via updateSettings
method. You can change all the settings that have been previously set and you can add new elements
To do this you need to have access to the instance of Handsontable outside the settings definition.
If that did not help please share a JSFiddle/StackBlitz example with the logic of envelopesColumn1Validator
and envelopesColumn2Validator