Set default filter for Kendo UI Grid

后端 未结 5 1636
我寻月下人不归
我寻月下人不归 2020-12-17 21:18

I have a Kendo UI grid that is rendered with javaScript. I want the string columns to have a single option (\"Contains\") and without the second filter. So far so good, I wr

5条回答
  •  抹茶落季
    2020-12-17 21:53

    The best way to change the default operator for all of the instances:

    kendo.ui.FilterMenu.prototype.options.operators =           
      $.extend(kendo.ui.FilterMenu.prototype.options.operators, {
      string: {
          contains: "Contains",
          startswith: "Starts with",
          eq: "Is equal to",
          neq: "Is not equal to",
          doesnotcontain: "Does not contain",
          endswith: "Ends with"
      }
    });
    

    and the complete script:

    kendo.ui.FilterMenu.prototype.options.operators =           
      $.extend(kendo.ui.FilterMenu.prototype.options.operators, {
    
    /* FILTER MENU OPERATORS (for each supported data type) 
     ****************************************************************************/   
      string: {
          contains: "Contains",
          startswith: "Starts with",
          eq: "Is equal to",
          neq: "Is not equal to",
          doesnotcontain: "Does not contain",
          endswith: "Ends with"
      },
      number: {
          eq: "Is equal to",
          neq: "Is not equal to",
          gte: "Is greater than or equal to",
          gt: "Is greater than",
          lte: "Is less than or equal to",
          lt: "Is less than"
      },
      date: {
          eq: "Is equal to",
          neq: "Is not equal to",
          gte: "Is after or equal to",
          gt: "Is after",
          lte: "Is before or equal to",
          lt: "Is before"
      },
      enums: {
          eq: "Is equal to",
          neq: "Is not equal to"
      }
     /***************************************************************************/   
    });
    

提交回复
热议问题