Kendo Grid - 如何在列标题中翻译文本“为真”,“为假”?

时间:2014-11-11 09:46:39

标签: kendo-ui kendo-grid translation

我在网格中有以下列标题(见下图):

enter image description here

我想问一下,我怎么能翻译“是真的”,“是假的”字符串?

非常感谢您的任何建议。

列:

 {
                    field :"active",
                    title : $translate.instant('ACTIVE'),
                    width:150,
                    filterable: {
                        cell: {
                            operator: "contains"
                        }
                    }
                },

型号:

 active: {
                                editable: true,
                                nullable: false,
                                type: "boolean"
                            },

2 个答案:

答案 0 :(得分:6)

您应该在filterable中定义以下消息:

filterable: {
    mode: "row",
    messages: {
        isFalse: "es falso",
        isTrue: "es verdadero"
    }
},

请参阅以下代码段中的实际操作:

$(document).ready(function () {
  $("#grid").kendoGrid({
    dataSource: {
      data: products,
      schema: {
        model: {
          fields: {
            ProductName: { type: "string" },
            UnitPrice: { type: "number" },
            UnitsInStock: { type: "number" },
            Discontinued: { type: "boolean" }
          }
        }
      },
      pageSize: 20
    },
    height: 550,
    scrollable: true,
    sortable: true,
    filterable: {
      mode: "row",
      messages: {
        isFalse: "es falso",
        isTrue: "es verdadero"
      }
    },
    pageable: {
      input: true,
      numeric: false
    },
    columns: [
      "ProductName",
      { field: "UnitPrice", title: "Unit Price", format: "{0:c}" },
      { field: "Discontinued", template: "#= Discontinued ? 'verdadero' : 'falso' #" }
    ]
  });
});
<link href="http://cdn.kendostatic.com/2014.2.1008/styles/kendo.common.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2014.2.1008/styles/kendo.default.min.css" rel="stylesheet" />
<script src="http://cdn.kendostatic.com/2014.2.1008/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.2.1008/js/kendo.all.min.js"></script>
<script src="http://demos.telerik.com/kendo-ui/content/shared/js/products.js"></script>

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

答案 1 :(得分:3)

基于kendoDocs你应该这样做:

...
filterable: {
    cell: {
        operator: "contains"
    },
    messages: {
        isTrue: $translate.instant('YES'),
        isFalse: $translate.instant('NO')
    }
}