Why is NumericTextBox saving the values as String in Mongodb?

I have added a NumericTextBox to event editor so users can enter a Distance (in kilometers). My code is like this:

let row: HTMLElement = createElement('div', {className: 'custom-field-row'});
let container: HTMLElement = createElement('div', {className: 'custom-field-container'});
let inputEle2: HTMLInputElement = createElement('input', {
className: 'e-field', attrs: {name: 'km'}
}) as HTMLInputElement;
row.appendChild(container);

let distanceTextBox:  NumericTextBox = new  NumericTextBox({

value: 88,
format: 'n0',
floatLabelType: 'Auto',
placeholder: 'Kilometers'
//enableRtl: true
});

distanceTextBox.appendTo(inputEle2);
inputEle2.setAttribute('name', 'km');


I have tried playing around with different settings, like format: 'n0' but the value gets saved as a string nevertheless and i cannot do any calculations with them.
Any help would be appreciated.

ScheduleData in the MongoDB:

{
    "_id": {
        "$oid": "5e8a43220e1de11fe051e670"
    },
    "km": "92", <- this value is in quotation marks, i need it to be a number
    "isFormal": false,
    "Subject": "ewfwefewf",
    "Location": "ewfwefewf",
    "StartTime": {
        "$date": "2020-04-11T16:30:00.000Z"
    },
    "EndTime": {
        "$date": "2020-04-11T17:00:00.000Z"
    },
    "IsAllDay": false,
    "StartTimezone": null,
    "EndTimezone": null,
    "Description": "wefwef",
    "RecurrenceRule": null,
    "Id": 7,
    "CreatedBy": "Bob"
}

1 Reply

HB Hareesh Balasubramanian Syncfusion Team April 8, 2020 12:28 PM UTC

Hi Youssef, 

Greetings from Syncfusion Support. 

We have validated your reported problem at our end and for that we have prepared a sample using popupClose event and it can be viewed from the following link, 

Code snippet: 
  onPopupClose(args: any): void { 
    if (args.type == "Editor") { 
      args.data.EventType = parseInt(args.data.EventType); 
    } 
  } 


Kindly try the above sample and if you have any other concerns please revert for further assistance. 

Regards, 
Hareesh 


Loader.
Up arrow icon