Posted 4 July 2022, 8:14 pm EST
Hello,
I have a table that has several columns. Lets assume the table consists of addresses with name, zip and city.
One of our requirements is not to have a duplicate entry inside the whole table (duplicate for combination of name, zip and city).
How can this be achieved with SpreadJS? With the validators that are offered I was not able to achieve this. I am missing here also the possiblity to iterate over the whole data in the table.
What I’d want is to have the possibility to validate based on a function that I am able to define, that either returns true or false as a validity check. This way I could then also hook into the ValidationError event via
sheet.bind(GC.Spread.Sheets.Events.ValidationError, function(e, args) { // do some thing. });
I tried searching here in the forum, and another user had a similar problem described here:
https://www.grapecity.com/forums/spreadjs/custom-cell-validator-spre
The proposed solution to use addCustomFunction does not make sense to me here, as this again, does not provide to iterate over the whole table and find duplicate entries accross several columns. The user itself said then that he used the editEvent, but here I am then missing the option to set the cell invalid programatically. How could this be done?
Another thing I tried is to use e.g. CellChange event and do my validation there (where I am able to iterate over the whole table and find duplicates). But here I am missing now the possibility to set the cell to invalid via code (without using any DataValidation offered by the API (GC.Spread.Sheets.DataValidation).
But then I’ll loose all the functionality that the DataValidation offers out of the box for showing users additional information (inputMessage, inputTitle, errorMessage, errorTitle and so on).
So to summarize:
- how to solve the uniqueness validation across the whole table?
- how to set the cell valid/invalid programatically?
- how to use a custom data validation without loosing the frameworks functionality of setting e.g. error messages and error titles?
Any help is appreciated.
Thanks in advance.