how to set first element of select2 jquery as default?
THE FOLLOWING CODE IS JUST PSEUDO CODE!
It is just an example to show you how I got 2 different examples and combined in a possible solution.
protected afterLoadEntity() {
super.afterLoadEntity();
// fill next number in new record mode
if (this.isNew())
this.form.YourFruitComboField = Northwind.FruitRow.getLookup().items.[0].FruitID
}
protected afterLoadEntity() {
super.afterLoadEntity();
if (this.isNew()) {
this.form.YourField.value = this.form.YourField.get_items()[0].id;
this.form.YourField.element.triggerHandler("change"); //if there is some change handler you've set
}
}