I have a multiselect widget that gets its initial values from my model and then reads from a datasource to get options. What i'd like to do provide users a button they can click to revert all changes made to the multiselect.
My Multiselect definition is below:
On the databound I invoke a function where i copy the existing value and _dataItems array into new arrays (this way i have what the original state of the widget was). Then in my function that is invoked by my cancel button i try to set the .value and .dataItem properties of the multiselect and refrech them but the UI doesn't update. Can someone see my flaw?
Ive debugged it and my array values are copied to my placeholder arrays and then back into the _values and _dataItems array properly but the UI doesn't reflect the change....
My Multiselect definition is below:
@(Html.Kendo().MultiSelect()
.Name(AMultiName)
.DataTextField("PrettyText")
.DataValueField("MapAbbreviation")
.Placeholder("Edit EMR maps...")
.Filter(FilterType.Contains).MinLength(3)
.AutoBind(false)
.DataSource(
ds => ds.Read(r=>r.Action("ReadMapOptions","EmrMappingKendo", new {Area="Messaging"})).ServerFiltering(true))
.Value(ASelectedOptions)
.Events(e =>
{
e.Change("onChangeEvent");
e.DataBound("saveInitialMultiValues");
})
)
//function invoked by dataBound
function
saveInitialMultiValues(multi) {
multi.sender._originaldataItems = multi.sender._dataItems.slice(0);
multi.sender._originalValues = multi.sender._values.slice(0);
}
//function invoked by my cancel button
function
cancelMultiSelectUpdates(multiId) {
var
multi = $(
'#'
+ multiId);
var
temp = multi.data(
"kendoMultiSelect"
);
temp._dataItems = temp._originaldataItems;
temp._values = temp._originalValues;
refresh();
}