Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numeric type value is converting to string #485

Open
majkelwork opened this issue Jul 29, 2024 · 3 comments
Open

Numeric type value is converting to string #485

majkelwork opened this issue Jul 29, 2024 · 3 comments
Assignees
Labels
feature New feature or request low Minor improvement/issue

Comments

@majkelwork
Copy link

Check if issue exists
Not exists, in revogrid version 2 is working

Describe the issue
I am using column numeral plugin and my data contains numbers with column type 'numeric'. When I edit a row in the datagrid, the value type is changing from number to string

To Reproduce
Codesandbox

@revolist revolist self-assigned this Jul 29, 2024
@revolist revolist added the bug Something isn't working label Jul 29, 2024
@revolist
Copy link
Owner

revolist commented Jul 30, 2024

Hi @majkelwork ,

Thank you for reporting this issue. We've investigated the problem and found that it’s related to how the numeric column type is currently implemented.

Issue Description

In the Revogrid version you're using, when editing a cell in a column with the type 'numeric', the value type changes from a number to a string. This is due to the editor component using HTMLInputElement.value, which captures the input as a string.

Findings

  • Current Behavior: The numeric column type only handles rendering, and the editor doesn’t automatically convert the string input to a number. This was intended to work this way from the beginning.
  • Version 2 Behavior: It’s possible that version 2 handled this differently, possibly due to the input returning a number by default.

Solution

To properly handle numeric values, we recommend manually parsing the input value to convert it to a number with beforeedit event.

Future Plans

We plan to improve this by automatically applying parseFloat for numeric inputs in future updates which would require use to create separate editor for number components. However, this feature is not currently prioritized, so for now, handling the conversion manually is the best approach.

Summary

  • Issue: Numeric column values are treated as strings after editing.
  • Current Handling: Input values are captured as strings.
  • Workaround: Manually parse the input using parseFloat.
  • Future Update: We’ll consider adding automatic conversion to number in a future release.

We appreciate your understanding and patience. If you have any more questions or need further assistance, please let us know!

Best regards,
Revolist Team

@revolist revolist added feature New feature or request and removed bug Something isn't working labels Jul 30, 2024
@revolist revolist added the low Minor improvement/issue label Jul 30, 2024
@revolist revolist moved this to To do in RevoGrid Backlog Jul 30, 2024
@majkelwork
Copy link
Author

@revolist
What is then the point of using columnTypes?
BeforeEdit is not a workaround, because the grid will still store data as string instead of number. Grid recognizes that an edit occurred when the change from number to string occurred. It causes excessive triggering of afterEdit, and I am not able to decide if the row was edited or only clicked.
The biggest bug occurs when the number is 0, because then it is removed and replaced with an empty string after click on cell editor.

@m2a2x
Copy link
Collaborator

m2a2x commented Jul 31, 2024

Hello @majkelwork I just fixed 0 case scenario for you, it's much bigger issue

@m2a2x m2a2x assigned m2a2x and unassigned revolist Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request low Minor improvement/issue
Projects
Status: To do
Development

No branches or pull requests

3 participants