有没有办法更改 kendo 网格中的 td 值?

Is there a way to change the td values in the kendo grid?

我有一个 kendo 网格,里面有数值。我想根据某些条件更改它们。像, 如果该值小于 10,我希望作为单元格中的值。 如果该值大于 40,我想将其颜色更改为红色。 如果值为负,我不想要“-”减号。

正在寻找实现它的方法kendo,但找不到。

您需要为此使用客户端模板。

大致如下:

$("#grid").kendoGrid({
  columns: [ {
    field: "MyNumericValue",
    template: "#if (MyNumericValue < 10) {#
        <span>#: MyNumericValue #<span>
      #} else if (MyNumericValue  > 40) {#
        <span style='color:red;'>#: MyNumericValue #<span>
      #}#"
  }],
  dataSource: ** datasource config here **
});

这应该让你继续:https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/columns.template

有关 kendo 模板的其他信息:https://docs.telerik.com/kendo-ui/framework/templates/overview

我刚刚在 Stack Overflow 上找到了类似的答案: