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.

data("ejDropDownList") is undefined.

Thread ID:

Created:

Updated:

Platform:

Replies:

117517 Nov 2,2014 12:41 PM Nov 3,2014 05:38 AM ASP.NET MVC 1
loading
Tags: DropDownList
CS
Asked On November 2, 2014 12:41 PM


I've created a simple dropdown list as such:

@Html.EJ().DropDownList("ddlLoginName").WatermarkText("Select Login Name").DropDownListFields(Sub(f) f.Text("LoginName").Value("Id")).Width("15em").Datasource(CType(ViewBag.listOfLogin,IEnumerable(Of Login)))

And tried to use the javascript to get its selected value:

$("#ddlLoginName").data("ejDropDownList")

The result is always empty/undefined.

It seems like data("ejDropDownList") works only in certain scenario but it wasn't documented.

Saranya Sivakumar [Syncfusion]
Replied On November 3, 2014 05:38 AM

Hi CS,

Thanks for using Syncfusion products.

We would like to let you know that, in Dropdownlist control we are having a method called “getSelectedValue” which is used to get the selected item value in the Dropdownlist. It returns null or undefined if we didn’t specify the value field in the Datasource. If we specify the value field then it will return the value of the selected item. We are having another method called “getValue” which is used to get the text of the selected item in the Dropdownlist. So include the following code snippet in the click event of the Button.

[Script]

function click()

    {

        var obj = $('#selectCar').data('ejDropDownList');

        var a = obj.getValue();

        alert(a);

    }

 

For your convenience we have prepared the sample based on your requirement, please find the sample from the following location.

Sample Location: Sample

You can also refer the following class reference link for JavaScript. Since, our ASP.NET MVC components are created as wrapper for the JavaScript components the properties, methods and events will be same for MVC components.

http://help.syncfusion.com/cr/js

Please let us know if you have further concern.

Regards,

Saranya.S


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.

;