Create an array including all the invalid cells in the hot.validateCells callback function

Tags: #<Tag:0x00007f8b1d9e6218>

Hello, I added custom validators to all my rows and everything is working well, but when clicking on submit i want to divide the table into 2 arrays after validation… one for the valid rows and a second array for the invalid rows… so i can save the valid rows with the errors in the database and print the invalid rows on another page for the user to fix them…

hot.validateCells(function(hotIsValid) {
if (hotIsValid === true) {
console.log(“create an array for all the valid cells”)
} else {
console.log(“create an array for all the invalid cells including the error of every cell”)
}
})

Hi @williamelturk

there’s no API for table splitting, but generally it is possible.

I would

  1. Use the afterValidate hook to get indexes of invalid rows
  2. Create a new table from this rows by using a FOR loop on the getDataAtRow
  3. Remove the inavlid rows by alter(‘remove_row’, index, amount)