I have a dropdownlist bound to an array of objects which is working fine.
e.g.
Lookups : [ {ID:1,Name:"Line 1"}, {ID:2,Name:"Line2"});
I then bind this :
<ejs-dropdownlist data-source="Lookups" />
I then want to change that list. Sometimes I add a new item:
Lookups.push({ ID:3, Name:"Line3"});
or remove an item:
Lookups.splice(1,1);
or change an item:
Lookups.splice(1,1,{ID:2,Name:"New Line2"});
However, the dropdown doesn't update to show those new values. I woudl have expected that since it is a vue component, the data binding would kick in.
I have played around with adding new item using the addItem() method on the dropdown. I have tried manipulating the dropdown's dataSource property (which seems to effectively modify my original Lookups list anyway). I have tried using a query but i can't see how I can manually force it to refresh the dropdown.
All I really want is for the dropdownlist to respect the databinding on the Lookups OR a "refresh()" method on the dropdown control to force it to rebind the list. How can I make this work?
I did see this but its using Vuex which isn't applicable in this case.
Regards
Jeff
I need to keep the list up to date. When I use the addItem() method I am getting conflict between the two. The addItem() definitely adds the item in but then it will sometimes also take the item I have added to the list as well. Its not consistent.
What I did get working was to copy my list to a temp variable, clear the dropdown list and then reassign the list again.
var tempList = JSON.parse(JSON.stringify(self.Lookups.SavedSearches));
self.Lookups.SavedSearches = [];
self.$nextTick(function () {
self.Lookups.SavedSearches = tempList;
});
Would be handy to have a refresh() method on the dropdown that could do this, or something similar.
|
var newobj = { Id: "Game10", Game: "Tennis" };
this.$refs.dropObj.ej2Instances.dataSource.push(newobj);
this.$refs.dropObj.ej2Instances.refresh(); |