简体   繁体   English

指定属性“multi:true”时,Kendo Grid 的列可过滤属性“ui”不起作用

[英]Kendo Grid's column filterable property "ui" not working when property "multi:true" specified

I am trying to create a multi checkbox filter for a Kendo grid column.我正在尝试为 Kendo 网格列创建一个多复选框过滤器。 For this feature I am using "multi:true" property on the column's filterable.对于此功能,我在列的可过滤项上使用“multi:true”属性。 I also want to use the "ui" callback function which does not seem to work when I have the "multi:true" property set.我还想使用“ui”回调函数,当我设置了“multi:true”属性时它似乎不起作用。 If I remove this property, the "ui:function(e){}" gets called.如果我删除此属性,则会调用“ui:function(e){}”。

Is there a way I can use both these together?有没有办法可以同时使用这两种方法?

Here is a link to the demo I am trying这是我正在尝试的演示的链接

Thank you in advance!先感谢您!

Setting the filter property of the grid data source does the trick.设置网格数据源的过滤器属性可以解决问题。

     <div id="grid"></div>

    <script>
      var onlyOnce = false;
      $(document).ready(function () {
        var crudServiceBaseUrl = "https://demos.telerik.com/kendo-ui/service",
            dataSource = new kendo.data.DataSource({
              transport: {
                read: {
                  url: crudServiceBaseUrl + "/Products",
                  dataType: "jsonp"
                }              
              },
              filter: {
                                logic: "or",
                                filters: [
                                { field: "ProductName", operator: "eq", value: "Chai" },
                                { field: "ProductName", operator: "eq", value: "Chang" }
                                ]
                            }
            });

        $("#grid").kendoGrid({
          dataSource: dataSource,
          columns: [
              { field: "ProductName", title: "Product Name", filterable:{
                multi:true
              } 
            }
           ],
          filterable: true                    
        });
      });  
    </script>  

The columns.filterable.ui is used for making a custom filter menu so if you choose to use that use it to create the filter UI plus any filter initialization you want. columns.filterable.ui用于制作自定义过滤器菜单,因此如果您选择使用它来创建过滤器 UI 以及您想要的任何过滤器初始化。 In case you want to just initialize the filter use the filtermenuopen event .如果您只想初始化过滤器,请使用filtermenuopen 事件

<div id="grid"></div>
    <script>
      $(document).ready(function () {
        var crudServiceBaseUrl = "https://demos.telerik.com/kendo-ui/service",
            dataSource = new kendo.data.DataSource({
              transport: {
                read: {
                  url: crudServiceBaseUrl + "/Products",
                  dataType: "jsonp"
                }              
              }             
            });

        $("#grid").kendoGrid({
          dataSource: dataSource,

          columns: [
                        { field: "ProductName", title: "Product Name", filterable:{
                 multi:true
                } 
            }
           ],
          filterable: true,
          filterMenuOpen: function(e) {
                        if (e.field == "ProductName") {
                        e.container.find("input[type=checkbox]").prop('checked', true);
                        }
                }
        });
      });  
    </script>  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM