Pardon my non-technical language. I’m not very familiar with technical terms.
I have 2 cells which are related to each other.
I wanna make sure that either one is not empty when the other one is not empty.
I had validated both of them based on data within each other.
But when I select both of them and delete their data at the same time, they can’t pass the validation and are marked red.
So I had to make my page render or validate the whole table after editing any one of the cells so it would appear to be normal.
But the table becomes extremely slow. Did I miss something? Is there a better way to do this?
when we delete content from A1, if B1 is not empty then A1 should be marked invalid;
when we delete content from B1, if A1 is not empty then B1 should be marked invalid;
If both cells are empty they are both valid
Consider this an inventory sheet. The business logic would be something like this:
Column A contains amount, while column B contains SKU.
There is no point having “amount” without specifying the product you are referring to, vise versa.
What I would love to achieve is when I delete content in A1 and B1 at the same time, they should be valid. But now they are both marked as invalid.
It would be hard to achieve with a validator but it might be possible via afterChange hook. The only flaw is that we won;t be able to use the predefined htInvalid class and we’d need to create a custom one.
The afterChange hook provides a full list of changes for all the cells so even if two cells are changed in the same time we have a control over what is going on.
The afterChange provides an array of changes. If the array is length > 1 then user made at least 2 changes (two+ cells were changed).
I’d love to create the logic for this hook for you but it exceeds my abilities as a part of the forum basic support. However, I can help if you’ll decide to build it by yourself.