Hi!
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:
$('#versorgung').ejDropDownList({
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)