Zero as a string in format for positive, negative, and zero values.

Hello,

Help me, please.
How I can get Zero as a string in format for positive, negative, and zero values?
For example "###;-###;Zero"

Thanks.

5 Replies 1 reply marked as answer

SN Sevvandhi Nagulan Syncfusion Team June 4, 2021 06:32 AM UTC

Hi Andrey, 


Greetings from Syncfusion support. 


We checked your query. We suggest that you to use the below custom format to achieve the reported requirement. Refer the below code. 


@Html.EJS().NumericTextBox("customformat").Value(250).Format("###.### Zero").Render() 


Kindly get back to us for further assistance. 


Regards, 
Sevvandhi N 



AK Andrey Kabanets June 4, 2021 07:45 AM UTC

Hi, Sevvandhi Nagulan,

This format output a string "0 Zero" то an input, but I want hide 0, and get a string "Zero".

Thank you.


SN Sevvandhi Nagulan Syncfusion Team June 7, 2021 10:42 AM UTC

Hi Andrey, 


We checked your query. The NumericTextBox component is a number component. So, we cannot assign the string zero to component instead of 0. So can you please provide the use case scenario for the reported requirement?. In addition, provide some example inputs for which are the inputs you need to replace 0 as zero in string. 


Regards, 
Sevvandhi N 



AK Andrey Kabanets June 7, 2021 12:20 PM UTC

Hi

Ok, my friend, let see: for example, we have some fields of limits of a user, we have a limit of phones or a limit of emails. How many phones or email addresses can have one user. Customers want to see the word "deny" or "forbidden" (I don't know...) when the value of this field equals 0. However, Customers want to see a string "default setting" when the value of this field equals null or empty this setting says the limit will set from a parent entity.

Thanks.


SN Sevvandhi Nagulan Syncfusion Team June 8, 2021 11:14 AM UTC

Hi Andrey, 


Thanks for sharing the information as requested. 


As we mentioned earlier, so we cannot assign the string value zero to component. Hence, we suggest that you to assign the value “zero” to the input element in the change event when the value is 0. Please refer the below code. 


@Html.EJS().NumericTextBox("customformat").Value(250).Change("onChange").Render() 
 
<script> 
    function onChange(args) { 
        var instance = document.getElementById('customformat').ej2_instances[0] 
        setTimeout(() => { 
            if (args.value == 0 || instance.value == null) { 
                instance.element.value = "Zero"; 
            } 
        }, 30) 
    } 
</script> 


Kindly get back to us for further assistance. 


Regards, 
Sevvandhi N 


Marked as answer
Loader.
Up arrow icon