We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Initialize and Access a Numeric Textbox

Thread ID:

Created:

Updated:

Platform:

Replies:

110775 Aug 24,2013 04:10 AM Sep 11,2013 07:16 AM JavaScript 13
loading
Tags: ejmTextBox
Michael G. Schneider
Asked On August 24, 2013 04:10 AM

There is some simple HTML/JS 

   <input id="test" type="text" />

   $("#test").ejNumericTextbox({ value: 123 });

This works. Now suppose I want to create a numeric textbox which initially has no value. I tried

   $("#test").ejNumericTextbox({ value: "" });
   $("#test").ejNumericTextbox({ value: undefined });
   $("#test").ejNumericTextbox({ value: null });

All failed because of "Uncaught setModel - Invalid input for property :value - Expected type - number". How should the initialization be done?

I access the value with

   $("#test").ejNumericTextbox("option", "value")
   
Suppose the user deletes the value of the numeric textbox (select the content, hit DEL). Then the above returns "1". Why?

Michael G. Schneider

Michael G. Schneider
Replied On August 24, 2013 06:47 AM

After more tests I am no longer able to reproduce my second observation "empty content being returned as 1". I will do more tests and try to find the cause for it.

However, there are two more questions.

ONE: If I access the value via

   $("#test").ejNumericTextbox("option", "value")

then the returned datatype depends on how the value was entered into the numeric textbox.
  • If a number is typed into the textbox, then the datatype if "string".
  • If one of the up/down buttons is clicked, then the datatype is "number", if the data is accessed from within "valueChange". And it is "string", if the data is accessed from outside.
Why is this so? I think it would be better, if the datatype were always one or the other.

TWO: I am not able to enter a 1000-separator into the textbox. Is this intended?

Michael G. Schneider

Saravanan G [Syncfusion]
Replied On August 26, 2013 09:16 AM

Hi Michael,

 

Thank you for using Syncfusion products.

 

Query 1 : Now suppose I want to create a numeric textbox which initially has no value.

 

Since NumericTextbox “value” supports only number type. To set no value initially, do the below step.

 

$('#numeric').ejNumericTextbox({ value: NaN });

 

Also, if we want to set the empty string, undefined and null value to numeric textbox, please convert that to number object like.

 

            $('#numeric').ejNumericTextbox({value: parseInt("")});

            $('#numeric').ejNumericTextbox({value: parseInt(undefined)});

            $('#numeric').ejNumericTextbox({value: parseInt(null)});

 

                              However while processing the above value with setModel , we have faced the issue empty string didn’t get updated. So we included this issue with query 2,3 issue report.

 

Query 2 :  I access the value with $("#test").ejNumericTextbox("option", "value") Suppose the user deletes the value of the numeric textbox (select the content, hit DEL). Then the above returns "1". Why?

Query 3 : The returned datatype depends on how the value was entered into the numeric textbox.

 

Sorry for this inconvenience, We are able to reproduce the issue reported in query 2 and 3 and we have logged an Issue report on this. We will update you with the fix for this issue in upcoming release.

 

Query 4: I am not able to enter a 1000-separator into the textbox. Is this intended?

 

Yes, we restrict the separator to be entered into textbox. Since Numeric textbox itself sets the separator on focus out.

                                                                                                                                                                                                            

Regards

Saravanan G


Michael G. Schneider
Replied On August 26, 2013 10:14 AM

Hello Saravanan,

thanks a lot for the answer.
  • Regarding "value: NaN". If I set the value that way, then access the value via ejNumericTextbox("option", "value"), no valid string/integer will be returned. Instead a jQuery object will be returned.
  • It is important that empty values are handled correctly with Essential JS. When creating a business application, a NULL that is stored inside a SQL database will make its way into a null in some Javascript object, which will finally be put into one of your widgets. Also when saving the values to the SQL database a NULL should be handled, without forcing the developer to do much work. So ideally, I appreciated if a Javascript null could be put into a widget's value.
  • No big deal, just a remark. Some people prefer to type the 1000-separator. So maybe you should also allow it. After all, I can paste a 1000-separator into your widget. Then you do accept it.
Michael G. Schneider

Saravanan G [Syncfusion]
Replied On August 27, 2013 09:12 AM

Hi Michael,

 

Thanks for your update ,

 

Query #1: Regarding "value: NaN".

Query #2: Empty values are handled correctly with Essential JS.

 

Sorry for the inconvenience, We have confirmed the defect of numeric textbox “value” data type as number, so we will change this data type to support both string as well as number. This fix will resolve the entire problem with numeric textbox and this changes will be reflected in our upcoming main release.

 

Query #3: Not able to enter a 1000-separator into the textbox?

 

We will analyses on this requirement and update you the status on  30 Aug 2013 . So please be patience until we will get back to you.

 

Regards

Saravanan G


Michael G. Schneider
Replied On August 27, 2013 10:50 AM

Hello Saravanan,

thanks a lot for the answer. I will test again, when the next version has been released.

Michael G. Schneider

Michael G. Schneider
Replied On August 27, 2013 01:11 PM

A similar problem exists with a DatePicker when trying to set its value to "empty".

Michael G. Schneider

Saravanan G [Syncfusion]
Replied On August 28, 2013 08:53 AM

Hi Michael,

 

We are sorry for inconvenience caused.

 

In beta release, we have not null value support for Datepicker control, we will implement this feature and it will be available in our upcoming main release. We will let you know once the release rolled out.

 

Regards

Saravanan G


Michael G. Schneider
Replied On August 28, 2013 09:09 AM

Hello Saravanan,

thanks a lot for the answer.

After having found out that ejNumericTextbox and ejDatePicker are not yet well prepared for storing an empty / null / blank value, I suspect that the other widgets also do not support this.

Will you look into the other widgets yourself? Or do I have to test it and report seperate issues for each widget?

I think it is important that all widgets (e.g. Gauges, TimePicker, AutoComplete, Progressbar, Rating, etc.) support an empty / null / blank value. In an LOB these widgets will be bound to data that was extracted from an SQL database, where a NULL value is quite common.

Michael G. Schneider

Saravanan G [Syncfusion]
Replied On August 29, 2013 10:18 AM

Hi Schneider,

 

We deeply regret for the inconvenience caused.

 

Currently We have not null value support for textbox controls(editors, autocomplete, datepicker, ..), and we need to ensure the remaining controls with null value. we will ensure these features in remaining controls and update you in 3 business days(3/Sep/2013), so we request you to please be patience until then.

 

Please let me know if you have any concerns.

 

Regards,

Saravanan G


Michael G. Schneider
Replied On September 5, 2013 03:14 AM

Hello Saravanan,

did you already decide if and how the null/empty values will be handled by your widgets?

Michael G. Schneider

Saravanan G [Syncfusion]
Replied On September 10, 2013 09:18 AM

Hi Michael,

 

Thank you for your update.

 

Textbox controls will accepts string and numbers data type. In this case our textboxes supports Null, undefined, empty string and NaN values, and  stores the value as empty string in model. We will follow the same procedure for all other widgets based on behaviour type.

 

Please let us know if you have any further queries.

 

Regards,

Saravanan G


Michael G. Schneider
Replied On September 10, 2013 10:02 AM

Hello Saravan,

perfect! I am looking forward to using the next release.

Michael G. Schneider

Saravanan G [Syncfusion]
Replied On September 11, 2013 07:16 AM

Hi Michael,

Thank you for your update.

We will let you know once the release has been rolled out.

Regards,

Saravanan G


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;