Hi everyone
I have a multiselect, its preloaded with "All", when I select a new option, it removes the all item from the select. What I want to do is add a section so that when the user selects "All" again, it clears all the other options except for all.
I have the following code, my dataItem.Value keeps giving me "undefined" I have changed to .value as well, no luck.
Here is the JS
Any ideas what I am doing wrong?
Thank you
I have a multiselect, its preloaded with "All", when I select a new option, it removes the all item from the select. What I want to do is add a section so that when the user selects "All" again, it clears all the other options except for all.
I have the following code, my dataItem.Value keeps giving me "undefined" I have changed to .value as well, no luck.
@(Html.Kendo().MultiSelectFor(m => m.ReportCriteria.ProductClassList)
.Name("ReportCriteria.ProductClassList")
.DataTextField("ProductClassDescription")
.DataValueField("ProductClassCode")
.Events(e => e.Select("onSelect"))
.AutoBind(true)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("ProductClassList", "Dashboard")
.Data("sendProductClassText");
});
source.ServerFiltering(true);
})
)
function
onSelect(e) {
var
allSelect = [
"All"
];
var
multi = $(
"#ReportCriteria_ProductClassList"
).data(
"kendoMultiSelect"
);
var
dataItem =
this
.dataSource.view()[e.item.index()];
alert(dataItem.Value);
if
(dataItem.Value ==
"All"
)
{
multi.value([
"All"
]);
}
if
(multi.value().indexOf(
"All"
) > -1)
{
var
values = multi.value().slice();
values = $.grep(values,
function
(a) {
return
$.inArray(a, allSelect) == -1;
});
multi.dataSource.filter({});
multi.value(values);
}
}
Thank you