0
votes

I have the following situation, a kendo grid and I want to select which filter operators, this works fine:

var filters_op = {
  operators: {
    string: {
      eq: "Is equal to",
      neq: "Is not equal to",
      contains: "Contains"
    }
  }
}

element.kendoGrid({
  dataSource: dataSource,
  filterable: filters_op,
  columns: ...
  ...
});

However my application is multi-language, and previous I had the property filterable: true (or false) and the vendor kendo global do the work to translate and brings its own filterable operators.

On the other hand, the default operators from Kendo Global contains some filters like "starts with", "Is after", "Is after or equal to"... which my application doesn't support yet, and when I override them, I lose the translation support from K.Global

Is it possible to have both, select which I want and the translate from K.Glbl together?

1

1 Answers

2
votes

You can't choose which one of the kendo global operators will be translated on the filterable parameter of your kendoGrid function. Kendo does not allow that, yet.

However, you can translate the operators by yourself (or by a third-party library) and provide them on the filters_op. That will override the kendo default filters and also translate them.

I recommend you to use the I18n.t translate method of the i18n to do that. Your code will look like this, for example:

var filtersOp = {
  operators: {
    string: {
      eq: I18n.t('kendo.grid.filterable.operators.string.eq'),
      neq: I18n.t('kendo.grid.filterable.operators.string.neq'),
      contains: I18n.t('kendo.grid.filterable.operators.string.contains')
    },
    date: {
      eq: I18n.t('kendo.grid.filterable.operators.date.eq'),
      neq: I18n.t('kendo.grid.filterable.operators.date.neq')
    },
    enums: {
      eq: I18n.t('kendo.grid.filterable.operators.enums.eq'),
      neq: I18n.t('kendo.grid.filterable.operators.enums.neq')
    }
  }
}

...

element.kendoGrid({
   ...
   filterable: filtersOp,
   columns: ...
   ...
})

As you can see, the I18n library will handle this translation procedure.