How do I verify the cell or Table?

Tags: #<Tag:0x00007f8b2b1f41c8>

Assuming that there is a table, the information on the table is currently imported into getSourceData and stored in the DB.

I was checking whether the data I brought to getSourceData was correct or not by turning it into the conditional statement I wrote, and when I happened to look it up in the document, there was a function called validatecell.

So I tried to use this function, but I didn’t think there was a related example, so I was curious how it was used exactly, so I left a question.

Currently, the action I want to do is simply to check whether the value that enters the cell is string or number.

Of course, I know that celltype can be changed to numbers and letters through rendering function, but only red is displayed on the screen, and exceptions are being processed separately.

Hi @curlydoggi

Could you share your recent progress in a demo? (just the part that you have to gather the data, without the server part)

Hi @curlydoggi

do we have any updates here or can we call it solved?

Sorry for the late response. Alexandra, I posted a question but I couldn’t care about it irresponsibly.

It is difficult to post a related example. I just want to verify it.

For example, when only numbers should be entered in hands-on-table, the user entered characters in hands-on-table. After that, I just want to make an exception so that when I use a function or try to take action, I can’t move on to that action.

If 0 or 1 is returned as a result of such verification, the result would prevent me from taking the next action or from doing it, is there any way?

To clarify @curlydoggi, in your use case user can type only digits in a cell editor and the editor will not close until they type a correct value?

It’s not that the table won’t close, it’s that the next function to be done is not executed.

For example, let’s say that there is a function in the table that inputs a number and adds it using that number.

If a string is entered in the table, the plus function should not be executed, of course, there will be an error on the console.

To prevent this case, I want to do cell validating and give a warning message to the user in case of an error.

Whether it’s a number or a letter, I want to give a validating option to the cell I want.

Are the things I mentioned above completely irrelevant to the validate cell of hands-on table?

OK so let’s confirm. Please confirm if I got it correct.

48 44

image

I think we look at each other differently. What I’m talking about is to validate if it’s entered incorrectly by the user like the table above.

If a character is entered in a cell where a number is to be entered, such as in the table above, and the next action (function) is executed without verification or exception processing, a problem will arise.

If this is a problem related to storing data in the DB, an error will occur because it does not fit the DB data type.

As a result, before executing a function related to the table, I want to identify the incorrectly entered cell and give a warning message to the user without executing the function if there is an error.

Are the things I said related to the validate cell?

Would afterValidate hook meet your requirements? When the cell editor is closed and the value turns red as invalid this hook is called. It returns

32

Within that hook, you will be able to attach your custom error message for the user.

Is there any example of using afterValidate?

Here is a simple example https://jsfiddle.net/b0wf1ra4/. Let me know if you would need anything more than that.

Thank you Alexandra, I was able to solve the problem. Is it okay to ask questions about verification from time to time?

Verification, what do you mean? Generally, we provide guidance related to any aspect of Handsontable.

Never mind. I said it wrong. Anyway, thank you always.

Thank you for the update. I’m closing this thread.