Default zero (0) is coming while using wijmo Number/Integer

Posted by: nilesh_nichal on 2 August 2024, 2:50 pm EST

    • Post Options:
    • Link

    Posted 2 August 2024, 2:50 pm EST

    Hi Team,

    We are getting by default zero (0) while using WjInputNumber, instead of empty value (for eg empty string).

    to set value we are using below code

    [code] @Input()

    public override set value(value: number) {

    if (value != this._value) {

    try {

    value = wjcCore.asInt(

    value,

    !this.isRequired || (value == null && this._value == null)

    );

    } catch (e) {}

      value = _.toInteger(value);
      value = _.isNaN(value) ? 0 : value;
    
      if (value == null) {
        this._setText('');
      } else if (!isNaN(value)) {
        let text = wjcCore.Globalize.format(value, this.format);
        this._setText(text);
      }
    }
    

    }[/code]

    Please resolve the issue so that instead of zero we can get empty value.

  • Posted 5 August 2024, 8:53 am EST

    Hi Nilesh,

    We can achieve your desired requirement, using isRequired=false and value=null. For more information checkout these API links

    isRequired: https://developer.mescius.com/wijmo/api/classes/Wijmo_Input.Inputnumber.html#isrequired

    value: https://developer.mescius.com/wijmo/api/classes/Wijmo_Input.Inputnumber.html#value

    <wj-input-number
          #number
          id="theNumber"
          [isRequired]="false"
          [value]="null"
        ></wj-input-number>

    Here is a sample https://stackblitz.com/edit/angular-f9t9z6?file=src%2Fapp%2Fapp.component.html for your reference.

    In case you face any issues, please let us know.

    Thanks, and Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels