【问题标题】:Suppress global ajax in kendo autocomplete MVC禁止剑道自动完成 MVC 中的全局 ajax
【发布时间】:2014-12-16 08:35:21
【问题描述】:

我有一个剑道自动完成框,它绑定到远程数据。 每当我在搜索框中输入内容时,我的默认 Ajax 加载动画都会弹出

我做了一些谷歌搜索,发现-->>> this 它说在 read 中包含 global: false 以抑制这种全局 ajax 行为

如何在 MVC 包装器中做到这一点?

     @(Html.Kendo().AutoComplete()
   .Name("productAutoComplete") 
   .DataTextField("ProductName") 
   .DataSource(source =>
    {
       source.Read(read =>
       {
            read.Action("GetProducts", "Home"); 
       })
       .ServerFiltering(true);
    })
 )

【问题讨论】:

    标签: ajax asp.net-mvc autocomplete kendo-ui


    【解决方案1】:

    我正在使用相同的场景。在互联网上搜索了几个小时后,我手上的唯一答案是“你不能用包装器来做。你必须通过 js 启动自动完成。”但后来我看到了另一种有意义的产品的另一种解决方案。

    这是我为我的项目所做的:

    在主js文件中;

    var ajaxStartActive = true;
    $(document).ajaxStart(
        function () {
            if (ajaxStartActive)
                $loading.show();
        }).ajaxStop(
        function () {
            $loading.hide();
        });
    

    与自动完成一起使用;

    @(Html.Kendo().AutoComplete()
       .Name("productAutoComplete")
       .HtmlAttributes(new { onfocus = "ajaxStartActive = false;", onblur = "ajaxStartActive = true;" }) 
       .DataTextField("ProductName") 
       .DataSource(source =>
        {
           source.Read(read =>
           {
                read.Action("GetProducts", "Home"); 
           })
           .ServerFiltering(true);
        })
     )
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-17
      • 1970-01-01
      • 2015-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-07
      相关资源
      最近更新 更多