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

Documentation example request for InputNumber with comma as decimal separator. #10975

Closed
1 task done
stumps-dev opened this issue Jun 20, 2018 · 11 comments
Closed
1 task done
Assignees

Comments

@stumps-dev
Copy link

stumps-dev commented Jun 20, 2018

  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

I needed InputNumber component to use comma as decimal separator, I searched answers on Google, and you guys basically said it's not possible.
It took way too long for me to find out how to do this, it would be nice if these examples could be added to the docs to save other developers some time with this problem.

What does the proposed API look like?

These InputNumber components should behave exactly like a normal InputNumber component but with a comma as decimal separator.

Regular InputNumber:

const inputRef = React.createRef()

<InputNumber
  ref={inputRef}
  formatter={value => value.toString().replace('.', ',')}
  parser={input => input.replace(/[^\w\,-]+/g, '')}
  onChange={value => {
    value = parseFloat(value.toString().replace(',', '.'))
    inputRef.current.inputNumberRef.setState({ value })

    //Do something with 'value'
  }}
/>

As a form Item:

<Form.Item>
  {getFieldDecorator('fieldName', {
    normalize: value => {
      if (value || value == 0)
        if (value.toString().match(/\d+,($|\d+)/))
          return value.toString().replace(',', '.')
        else
          return value
    }
  })(
    <InputNumber
      formatter={value => value.toString().replace('.', ',')}
      parser={input => input.replace(/[^\w\,-]+/g, '')}
    />
  )}
</Form.Item>
@5679361
Copy link

5679361 commented Jun 27, 2018

非常有用。

@afc163
Copy link
Member

afc163 commented Jul 16, 2018

PR is welcome

@IssueHuntBot
Copy link

@BoostIO funded this issue with $15. Visit this issue on Issuehunt

@IssueHuntBot
Copy link

@0maxxam0 funded this issue with $10. Visit this issue on Issuehunt

@ghost
Copy link

ghost commented Aug 14, 2018

@hengkx
Copy link
Member

hengkx commented Aug 31, 2018

In what scenario is this used?

@IssueHuntBot
Copy link

@loadbalance-sudachi-kun funded this issue with $256. Visit this issue on Issuehunt

1 similar comment
@IssueHuntBot
Copy link

@loadbalance-sudachi-kun funded this issue with $256. Visit this issue on Issuehunt

@IssueHuntBot
Copy link

@amedora has started working. Visit this issue on Issuehunt

@IssueHuntBot
Copy link

@amedora has submitted output. Visit this issue on Issuehunt

@IssueHuntBot
Copy link

@yesmeck has rewarded. Visit this issue on Issuehunt

@yesmeck yesmeck closed this as completed Sep 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants