I have a set of ComboBoxes whose items come from the same DataSource.Read event. In certain cases, I want to filter the items. My ComboBox looks like this:

@(Html.Kendo().ComboBox()
    .HtmlAttributes(new { style = "font-size:10px; background-color: #f4f4f4;" })
    .Name(string.Format( "{0}{1}", p, f[0] ) )
    .Placeholder("Choose a value...")
    .DataTextField("Name")
    .DataValueField("Value")
    .DataSource( source => 
    {
        source.Read( read => read.Action( "MyMethod", "MyController", new { _type = f[2] } ) )
            .Events( e => e.RequestEnd( f[0] == "F1" && p != "P1" ? "SetFilter" : "NoFilter" ) );
    } )
)

The variables, p, and f[x] are strings from a couple of foreach loops that I am running. As I run through those loops, my intention is to leave the DataSources alone except in the cases where f[0] == "F1" and p != "P1".

My two functions look like this:

function NoFilter() { }

function SetFilter( e ) {
    var $filter = new Array();
    $filter.push({ field: "Name", operator: "startswith", value: "O" });
    e.sender.filter({ logic: "or", filters: $filter });
}

Altogether, I have twelve combo boxes that I am loading, of which two fit my exceptions. When the editor comes up, all the combo boxes briefly show wait indicators while they load. This all works well, except that the wait indicators for my two exceptions never go away, even though the filters are applied as I wish.

What am I missing that is leaving the wait indicators running?

有帮助吗?

解决方案

Seems like you are recursively calling the server since you are setting a filter after reading the data. Setting a filter to the datasource will call the read method with the filter again. That means it will call the RequestEnd method again (Never ending).

Instead doing this way try to set the filter after the creation of the grid.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top