Problem is handsondtable just access to source callback when I click to a cell after that It didn’t access to source callback when I’m typing. my config below.
container = document.querySelector(elements.dataCorrectionContainer)
settings = $.extend({}, tableSettings, {
columns: [
{
data: 'origin_input'
editor: false
}
{
data: 'correct'
type: 'dropdown'
renderer: (instance, td, row, col, prop, cellValue, cellProperties) =>
cellValue = SN.Utils.inBrackets(cellValue)
classType = instance.getDataAtRowProp(row, 'classType')
classNames =
"#{enum_class_type.blue_many_results}": 'background-blue'
"#{enum_class_type.yellow_not_found}": 'background-yellow'
"#{enum_class_type.green_changed}": 'background-green'
$.each instance.getCellMetaAtRow(row), ->
this.className = classNames[classType]
Handsontable.renderers.TextRenderer.apply(this, arguments)
strict: false
allowInvalid: true
trimDropdown: false
source: (query, process) ->
self.dataCorrectionLastSource = []
self.searchLocation query, (data) ->
self.hashLocationToID = self.locationsToHashNameID(data)
self.hashLocationToCode = self.locationsToHashNameCode(data)
sources = $instance.locationsToSource(data)
self.dataCorrectionLastSource = sources
process(sources)
validator: (value, callback) ->
table = this.instance
source = table.getSourceDataAtRow(this.row)
location_id = $instance.hashLocationToID[value] || NOT_FOUND_ID
$instance.suspiciousHash[source.origin_input].location_id = location_id
table.setDataAtRowProp(this.row, 'location_id', location_id, CHANGE_BY_APP)
location_code = $instance.hashLocationToCode[value] || undefined
$instance.suspiciousHash[source.origin_input].location_code = location_code
table.setDataAtRowProp(this.row, 'location_code', location_code, CHANGE_BY_APP)
if self.dataCorrectionLastSource.length == 0
table.setDataAtRowProp(this.row, 'classType', enum_class_type.yellow_not_found, CHANGE_BY_APP)
else if value != source.old
table.setDataAtRowProp(this.row, 'classType', enum_class_type.green_changed, CHANGE_BY_APP)
callback true
}
{
data: 'old'
}
{
data: 'classType'
}
{
data: 'location_id'
}
{
data: 'location_code'
}
]
hiddenColumns:
columns: [2,3,4,5]
stretchH: 'all'
strict: true,
rowHeaders: true
colHeaders: [ 'Suspicious Value', 'Correct Value', 'Old value', 'Type', 'location_id', 'location_code']
fixedRowsTop: 0
preventOverflow: false
minSpareRows: 0
width: '95%'
height: 500
data: self.suspiciousData()
})
self.dataCorrenctionTable = Handsontable(container, settings)