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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I select the initial value if this might be different at times?

Thread ID:





132834 Sep 24,2017 12:21 PM UTC Sep 25,2017 09:05 AM UTC JavaScript 1
Tags: ejDropDownList
Paul Kocher
Asked On September 24, 2017 12:21 PM UTC


I'm using the actionComplete event to initialize a schedule and want to use the change event to only refresh the appointments and resources of the schedule.

Now I realized that if I use "selectedIndex" on the DropDownList, both events will eventually fire because the selectedIndex seems to trigger the "change" event.

I used console.log to see which one fires first and it actually is the change event being run first.

So now in order to make use of the "change" event I would have to initialize the schedule everytime I select a different item in the DropDownList.

Thinking about it I wanted to use the "value" member of the DropDownList to set the initial value - the items in the list are ordered alphabetically so if I add another entry to the dataSource the first item right now probably wouldn't be the first one.

What I tried:

I ran a query to get the Id of the first element:

var firstId = '';
        var dataManager = ej.DataManager("/Dienst/GetVersorgung");
        var query = ej.Query().select("Id").take(1);
        var execute = dataManager.executeQuery(query) // executing query
            .done(function (e) {
                firstId = e.result[0].Id;

then I tried to assign this to the value member:

            dataSource: dataManager,
            fields: {
                text: 'FullName',
                value: 'Id'
            value: firstId

this doesn't work. When I console.log(firstId) I get the following: be46d25a-7932-4433-a3a5-a27de1a67387
When I copy this and set value: "be46d25a-7932-4433-a3a5-a27de1a67387" everything works.

Is there a way to fix this? How can I make sure always the first entry of the dataSource gets selected (by using the value member)

Keerthana Rajendran [Syncfusion]
Replied On September 25, 2017 09:05 AM UTC

Hi Paul,   
Thank you for contacting Syncfusion support.   
We have prepared a simple sample based on your requirement. Please refer to the below given link   
We suggest you to set the value property via setModel of DropDownList in actionComplete event which will be triggered after fetching the data and you can get the result of executed query in arguments of actionComplete event. Please refer to the below given code   
          dataSource: dataManager,   
          fields: {   
            text: "CustomerID"   
          query: query,   


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.

Please sign in to access our forum

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

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