)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

Why the getSelectedValue method always returns the value in string, even the value in some other data type? Is there any way to achieve that?

Platform: jQuery |
Control: ejDropDownList |
Published Date: August 2, 2016 |
Last Revised Date: June 13, 2017

Description

By default, getSelectedValue method is used to retrieve the items value that are selected in the DropDownList. It returns the item value in the “string” data type instead of corresponding data type of the item.

 

Solution

But, using itemValue property, we can get the selected items as it is. But the “itemValue” property is only applicable for Single Selection mode in the DropDownList.

 

In the following example, upon selecting the items in the DropDownList, the change event will be triggered. In the change event, itemValue will returns the selected value in the DropDownList and the returned value will be in its corresponding data type.

 

For reference, we have added the local method called “toType” which receives the selected value from the DropDownList and returns the data type of the value.

 

Please refer the following code snippet.

Javascript

 

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon