在Kendo UI Grid Columns上执行自定义算术运算

时间:2013-04-17 10:26:47

标签: javascript jquery html5 kendo-ui kendo-grid

这对于普通用户来说可能非常简单,但作为一个新手,我有点难以表现 简单的arithemetic操作,我希望将其中一个列值,即(DealValue)乘以0.05。我查看了剑道文档,但令人惊讶的是我找不到任何相关内容。有人得到任何解决方案吗?如果我运行此代码,我会在DealValue列的模板部分得到errror,导致网格无法显示。

这是我的Kendo网格列定义

            columns: [           
               {
                   field: "DealIssuer",
                   width: 150,
                   title: "Issuer",
                   filterable: {
                       operators: {
                           string: {
                               startswith: "Starts With",
                               contains: "Contains"
                           }
                       }
                   },

                   template:"<a>${DealIssuer}</a>"

               },
                  {
                      field: "Ticker",
                      width: 150,
                      title: "Ticker",
                      filterable: {
                          operators: {
                              string: {
                                  startswith: "Starts With",
                                  contains: "Contains"
                              }
                          }
                      }

                  },
                  {
                      field: "DealExchange",
                      width: 150,
                      title: "Exchange",
                      filterable: {
                          operators: {

                              string: {
                                  startswith: "Starts With",
                                  contains:"Contains"
                              }
                          }
                      }
                  },
                     {
                         field: "DealType",
                         width: 150,
                         title: "Type",
                         filterable: {
                             operators: {
                                 string: {
                                     startswith: "Starts With",
                                     contains: "Contains"
                                 }
                             }
                         }

                     },
                        {
                            field: "DealValue",
                            width: 150,
                            title: "Value ($)",
                            filterable: {
                                operators: {
                                    string: {
                                        startswith: "Starts With",
                                        contains: "Contains"
                                    }
                                }
                            },
                            template:'${${DealValue}*0.05}'


                        },
                           {
                               field: "DealStatus",
                               width: 150,
                               title: "Status",
                               filterable: {
                                   operators: {
                                       string: {
                                           startswith: "Starts With",
                                           contains: "Contains"
                                       }
                                   }
                               }

                           },
                 {
                     field: "DealPricingCompletionDate",
                     width: 230,
                     title: "DealPricingCompletionDate",
                     format: "{0:dd/MM/yyyy}",
                     //  template: '#= kendo.toString(StartDate, "dd/MM/yyyy") #',
                     filterable: {
                         ui: "datetimepicker",
                         operators: {
                             date: {
                                 gt: "After",
                                 lt: "Before",
                                 eq: "Equals"
                             },
                             messages: {
                                 filter: "Apply",
                                 clear: "Clear"
                             }
                         }

                     }
                 },

            ],

1 个答案:

答案 0 :(得分:4)

破解了。 这是解决方案

                    columns: [
                     {
                            field: "DealValue",
                            width: 150,
                            title: "Value ($)",
                            filterable: {
                                operators: {
                                    string: {
                                        startswith: "Starts With",
                                        contains: "Contains"
                                    }
                                }
                            },
                            template:'${DealValue*0.05}'                             

                        }
                        ]