【问题标题】:Kendo Grid - How to translate text "is true", "is false" in the column header?Kendo Grid - 如何在列标题中翻译文本“是真的”、“是假的”?
【发布时间】:2014-11-11 09:46:38
【问题描述】:

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

我想问一下,“is true”、“is false”字符串如何翻译?

非常感谢您的任何建议。

列:

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

型号:

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

【问题讨论】:

  • 你能显示你初始化它的代码吗?
  • 我更新了我的问题。

标签: kendo-ui kendo-grid translation


【解决方案1】:

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

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

在下面的 sn-p 中查看它的实际效果:

$(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>

【讨论】:

    【解决方案2】:

    基于kendoDocs,你应该这样做:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-23
      • 1970-01-01
      相关资源
      最近更新 更多