【问题标题】:Kendo grid number formatting as percentage issue剑道网格数字格式为百分比问题
【发布时间】:2015-12-29 03:38:33
【问题描述】:

我正在使用以下格式显示数字值:

columns.push(
            {
                field: key,
                hidden: false,
                format: "{0:p2}"
            });

当该字段应该显示1.00%时,它会显示100.00%,就像任何给定值it's adding zeros一样,还有一个值是65.37%,输出是6,537.00%

我缺少任何设置或格式有什么问题? 问题是我正在动态创建网格,因此无法显示完整的网格设置。

在上面你可以看到我正在推送列,这是一个数组,将传递给创建网格的函数。

【问题讨论】:

    标签: kendo-ui telerik kendo-grid string-formatting number-formatting


    【解决方案1】:

    对于小数精度:

    format="##.0000 \%"
    

    【讨论】:

      【解决方案2】:

      Telerik Kendo UI for Angular: 以上对我不起作用。继续将 80% 转换为 800%

      这行得通:

      format="#=Percentage# \%"
      

      【讨论】:

        【解决方案3】:

        请尝试以下代码 sn-p。

        <div id="grid"></div>
        <script>
            $("#grid").kendoGrid({
                dataSource: {
                    data: [
                      { id: 1, increase: 1.00 },
                      { id: 1, increase: 65.37 }
                    ],
                    schema: {
                        model: {
                            id: "id",
                            fields: {
                                increase: { type: "number" }
                            }
                        }
                    }
                },
                columns: [
                  { field: "id" },
                  {
                      field: "increase",
                      template: '#=kendo.format("{0:p}", increase / 100)#'
                  }
                ]
            });
        
        </script>
        

        如果有任何问题,请告诉我。

        【讨论】:

          【解决方案4】:

          当您将值格式化为百分比时,kendo 中没有内置 mechanizm 来乘以它。这只能通过乘除该值来完成。 Here some example

          如果你只想用百分号显示值,你需要使用模板:template: "&lt;span&gt;#=fieldName# %&lt;\span&gt;"

          【讨论】:

          • 我只在这个网格中显示值并且编辑是在不同的网格中完成的,我怎样才能使这个网格相应地工作
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-04-18
          • 2018-09-21
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多