Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KendoUI grid - disable some filter operators per column

I want to disable (or maybe define some custom list of) operators per column. I tried to do this in columns definitions:

"field": "Name",
"title": "name",
"attributes": {
    "class": "nameCell"
},
"filterable": {
    "operators": gridTranslationService.getHierarchyOperators()
}

But it not works for me. Any sugestions how can I do that ?

like image 626
lukisp Avatar asked Dec 01 '14 10:12

lukisp


1 Answers

Set status column definition as:

    columns: [
      {
        field: "status",
        filterable: {
          operators: {
            string: {
              eq: "Equal to",
              neq: "Not equal to"
            }
          }
        }
      },

$(document).ready(function() {
  $("#grid").kendoGrid({
    columns: [
      { field: "id", filterable: false },
      {
        field: "status",
        filterable: {
          operators: {
            string: {
              eq: "Equal to",
              neq: "Not equal to"
            }
          }
        }
      }
    ],
    filterable: true,
    dataSource: [ 
      { status: "error", id: 1 }, 
      { status: "warning", id: 2 },
      { status: "warning", id: 3 },
      { status: "warning", id: 4 }
    ] 
  });
});
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.rtl.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.default.min.css">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.3.1119/js/kendo.all.min.js"></script>

<div id="grid"></div>
like image 99
OnaBai Avatar answered Sep 24 '22 11:09

OnaBai