2016-03-29 57 views
0

我尝试从Kendo网格过滤器的下拉列表中删除一个项目。但它仍然呈现。我怎样才能达到这样的行为?从Kendo网格过滤器中删除选项

$("#grid").kendoGrid({ 
    columns: [ 
    { field: "someDate", type: "date" } 
    ], 
    dataSource: [ 
    { someDate: "2016-3-29"}, 
    { someDate: "2016-3-30"} 
    ], 
    filterable: { 
    extra: true, 
    operators: { 
     date: { 
     gte: "Is after or equal to", 
     lte: "Is before or equal to" 
     } 
    } 
    }, 
    filterMenuInit: function(e) { 
    e.container.find("select:eq(0)>option")[1].remove(); 
    e.container.find("select:eq(1)>option")[1].remove(); 
    e.container.find("select:eq(2)>option")[0].remove(); 
    } 
}); 

Link on dojo。 请帮忙。

编辑: 我需要两个复杂的日期过滤器。在第一个过滤器中,我只需要“等于或等于”,然后是“AND”,而在第二个过滤器中,我只需要“等于或等于”。我尝试通过从第一个下拉列表中删除“Is before或equal to”,并从第二个下拉列表中删除“Is after or equal to”。

回答

1

,而无需删除你只能你想要什么

filterable: { 
       extra: false, 
       operators: { 
       string: { 
        startswith: "Starts with", 
        eq: "Is equal to", 
        neq: "Is not equal to" 
          } 
         } 
       }, 
+0

它不会帮助我。我需要两个复杂的日期过滤器。在第一个过滤器中,我只需要“等于或等于”,然后是“AND”,而在第二个过滤器中,我只需要“等于或等于”。我不能这样做。 – Neshta

+0

为了更加清晰,我添加了一些细节。 – Neshta

1

你需要得到kendoDropDownList对象,然后从数据源中添加项目;我已更新您的dojo

<script> 
    $("#grid").kendoGrid({ 
     columns: [ 
      { field: "name" } 
     ], 
     dataSource: [ 
      { name: "Jane Doe"}, 
      { name: "John Doe"} 
     ], 
     filterable: true, 
     filterMenuInit: function(e) { 
     if (e.field == "name") { 
      var filter1 = e.container.find("select:eq(0)").data("kendoDropDownList"); 
      var filter2 = e.container.find("select:eq(2)").data("kendoDropDownList"); 
      filter1.dataSource.remove(filter1.dataSource.at(0)); 
      filter1.select(0); 
      filter2.dataSource.remove(filter2.dataSource.at(0)); 
      filter2.select(0); 
      } 
     } 
    }); 
</script> 
+0

将dojo代码更新为您编辑的示例: http://dojo.telerik.com/EPegi/7 – Failwyn

+0

它在第一次加载网格时起作用。但如果按下清除按钮,则第一个下拉列表将被重置为空值。我想它设置了被删除的默认值。 – Neshta

+0

这在技术上是一个破解,因为它是设置一个成员的价值是私有的......但它的工作原理是... ... filter1._initial ='lte'; http://dojo.telerik.com/EPegi/11 – Failwyn

相关问题