BUG: Keytable Functionality

BUG: Keytable Functionality

pybcgpybcg Posts: 41Questions: 10Answers: 0

Link to test case: https://editor.datatables.net/examples/extensions/excel.html
Debugger code (debug.datatables.net):
Error messages shown: Input not valid
Description of problem:
I'm looking at the salary column and trying to copy and paste and it attempts to copy the data that was RENDERED rather than the underlying data so therefore, you get an improper format error ("input not valid"). How do you use copy+paste keytable functionality on columns that have a special rendering?

Answers

  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin

    You'd need to have a deformatter to convert the formatted value into a plain numeric one. e.g. in this case you could simply strip out the $ and , (assuming US number style input).

    Allan

  • pybcgpybcg Posts: 41Questions: 10Answers: 0
    edited July 2020

    Allan,

    1. Thanks for the heads up. Do you think a deformatter is something we can add to the documentation?

    2. So would you say the best way is to use the deformatter when I'm doing CTRL+C so that the right number is stored on my clipboard?

    3. I'm only seeing this issue when I copy+paste. Do you foresee any other instance I should accommodate for to make sure I don't have this issue?

    4. I have a render property for my number fields. Is there a reverse render method? I'd rather do something like that than to strip the commas because there will be instances when I will be doing things in US dollars or EUROs, and commas/periods are often switched.

  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin

    Do you think a deformatter is something we can add to the documentation?

    Available here: https://editor.datatables.net/manual/php/formatters . Use a set formatter in this case. That will then allow the user to submit things such as $1,000 as well. You'll probably need to update the validation you are using for the field to allow for that type of input as well.

    The other option is to use preSubmit to modify the data before it is sent to the server.

    So would you say the best way is to use the deformatter when I'm doing CTRL+C so that the right number is stored on my clipboard?

    No - because you wouldn't be able to control that if someone selected the data from a different web-page, or another app - e.g. Excel. You need to do it once pasted on (or possibly on paste).

    I'm only seeing this issue when I copy+paste. Do you foresee any other instance I should accommodate for to make sure I don't have this issue?

    Not that I can think of.

    I have a render property for my number fields. Is there a reverse render method?

    No sorry. You could just remove all non-numeric characters, but you need to be cause about negatives, comma decimals, etc.

    Allan

This discussion has been closed.