Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Handsontable hooks
cells (row, col, name) {
if (!this.hot) {
return null
}
const rowData = this.hot.getSourceDataAtRow(row)
if (rowData) {
if (rowData.state === NegotiationItemState.removed) {
return { readOnly: true }
}
}
},
afterRenderer (td, row, col, prop, value, column) {
if (!this.hot) {
return
}
// if invalid, add row and prop to cell so tippy can render
if (column.valid === false) {
td.setAttribute('row', row)
td.setAttribute('prop', prop)
}
// otherwise, destroy tippy instance on cell if it exists
else {
if (td._tippy) {
td._tippy.destroy()
}
}
// styles
// row data (from table instance data property)
const rowData = this.hot.getSourceDataAtRow(row)
// html class to be returned at end of function
let className = ''
// add classes based on columns setting
if (column) {
// user-supplied class name
className += ' ' + (column.className || '')
// read only column
if (!column.editor) { // column.readOnly ||
className += ' htReadOnly'
}
}
// cell was edited
const edited = this.changes.get(row, column.data)
if (edited) {
className += ' htEdited'
}
// add classes based on source data
if (rowData) {
// properties were updated
if (Array.isArray(rowData.propertiesUpdated) && rowData.propertiesUpdated.includes(prop)) {
className += ' htUpdated'
}
// quantity
if (rowData.type === 'loan' && rowData.quantity === 0) {
const colQuantity = this.settings.columns.find(col => col.data === 'quantity' || col.data === 'quantityRequired')
if (colQuantity) { // && !colQuantity.allowEmpty // custom `Quantity` column setting
className += ' htRemove'
}
}
if (rowData.type === 'loan') {
// console.log(column, rowData)
}
// removing
if (rowData.remove) {
className += ' htRemove'
}
// removed
if (rowData.state === NegotiationItemState.removed) {
className += ' htRemoved'
}
}
// return new meta data
td.className += className + ' '
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.