Field type plugins related (Mask)

Field type plugins related (Mask)

ktadrowskiktadrowski Posts: 13Questions: 5Answers: 0
edited November 2023 in Free community support

Hello,

I am using Datatables + Editor with vue js and node modules.
I have integrated mask plugin.

I used the code from respective plugin pages.
The mask plugin works perfectly. But I want to use it with different locales.

I am already using i18n option for my datatable, which works fine when displaying the labels of table, date picker etc.
I want to change the masking depending on the selected local.
e.g. if user locale is 'en' number field should be mapped with decimal separator as dot and thousand separator as comma.
and incase of user local as 'de' the decimal separator should be comma and thousand separator as dot.
Below code work fine till thousand, but fails for large numbers, in millions / CRs / billions etc.

{
          name: "unit_cost",
          label: t("invoice.details.timekeeper.hr_rate"),
          type: "mask",
          mask: (userStore.getUserLanguage === 'de' ? "#.##0,##" : "#,##0.##"),
          maskOptions: {
            reverse: true,
            placeholder: "10.50",
          },
        },

For locale 'DE'
input number: 445667123456.79
expected output is: 445.667.123.456,79
actual output is: 445,667,123.456,79

Is there a better way to mask field with i18n?

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,022Questions: 1Answers: 9,951 Site admin
    Answer ✓

    It looks like you might have hit a bug in that plug-in there I'm afraid, it might be a question for the author of the jQuery Mask Plug-in - although it doesn't look like it is maintained any more.

    One thing that does stand out to me though - userStore.getUserLanguage should that be a function call (i.e. userStore.getUserLanguage())? It sounds like it from the parameter name.

    With that old plug-in no longer being maintained, I'll look at others to provide a plug-in for Editor. This one looks good.

    Allan

  • ktadrowskiktadrowski Posts: 13Questions: 5Answers: 0

    Thanks Allan,
    Will check other plugins just in case!

Sign In or Register to comment.