@(Html.Kendo().MultiSelect()
.Name(Html.Name(ReflectionExtensions.GetName((IAddressViewModel x) => x.SuburbId)).ToString())
.DataTextField("DisplayName")
.DataValueField("Id")
.Placeholder("Select products...")
.AutoBind(false)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetSuburbsByCountry", "Data").Data("siberia.address.filterSuburbByCountryIdParameter");
})
.ServerFiltering(true);
})
当我点击这个kendo multiselect组件时,它会向服务器发送ajax调用获取数据,但我再次点击它不发送ajax请求。它显示缓存(以前返回的数据)。我需要每次都发送一个ajax调用。(需要mvc wrapper,transport - > cache:false)。
答案 0 :(得分:1)
@(Html.Kendo().MultiSelect()
.Name(Html.Name(ReflectionExtensions.GetName((IAddressViewModel x) => x.SuburbId)).ToString())
.DataTextField("DisplayName")
.DataValueField("Id")
.Placeholder("Select Suburb")
.AutoBind(false)
.Events(e => { e.Filtering("siberia.address.onSuburbFiltering"); })
.MinLength(1)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetSuburbsByCountry", "Data").Data("siberia.address.filterSuburbByCountryIdParameter");
})
.ServerFiltering(true);
})
-------------------------------------------------------------------------
function onSuburbFiltering() {
var currentSuburbId = '#' + prefix + 'SuburbId';
$(currentSuburbId).data().kendoMultiSelect.dataSource.read();
}
-------------------------------------------------------------------------
function filterSuburbByCountryIdParameter() {
var currentCountryId = '#' + prefix + 'CountryId';
var currentSuburbId = '#' + prefix + 'SuburbId';
var selectedCountry = $(currentCountryId).data("kendoDropDownList").value();
var surburbFilterText = $(currentSuburbId).data("kendoMultiSelect")._prev;
return {
SelectedCountryId: selectedCountry,
Text: surburbFilterText
}
}