gpt4 book ai didi

angularjs - 计算字段未使用 Kendo-UI 网格和 AngularJS 更新

转载 作者:行者123 更新时间:2023-12-05 00:24:53 24 4
gpt4 key购买 nike

我有一个带有订单线的 kendo-ui 网格。有一个Qty , PriceTotal柱子。总计列计算 ( Qty x Price ) .

对于编辑,我使用自定义弹出窗口显示一些附加信息并让用户更改 QtyPrice .当他们这样做时,我想要 Total在自定义编辑表单中自动更新。

这是总列的网格列定义:

{
field: "total",
title: "Total",
width: 60,
template: "#=qty*price#"
}

这是编辑表单中的输入字段:
<input name="total" style="width: 60px" />

这是问题:当我在编辑表单中更改数量或价格时,总计仅在网格中更新(位于弹出编辑表单下方),但编辑表单中的总计字段不会(它为空)。

作为测试,我把两个 #=total##=qty*price#在编辑表格中;
  • 前者为空
  • 后者是静态数字,它是
    表单呈现时的计算

  • 它没有得到更新。

    这是一个显示问题的 Plunker:
    http://plnkr.co/edit/cZw18btauqb9RPEpd5Kc?p=preview

    如何计算编辑表单中的总字段?
    (最好使用 Kendo-ui 模板机制或 AngularJS,但 jQuery hack 会作为最后的手段)?

    最佳答案

    模板不提供双向数据绑定(bind),因此它们在首次生成后不会自动更新。

    您可能希望在数据源架构中为您的模型使用计算字段:

    schema: {
    model: {
    id: "itemNo",
    fields: {
    id: {
    type: "string",
    editable: false
    },
    price: {
    type: "number"
    },
    qty: {
    type: "number"
    }
    },
    total: function () {
    return this.get("qty") * this.get("price");
    }
    }
    },

    ( demo)

    关于angularjs - 计算字段未使用 Kendo-UI 网格和 AngularJS 更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25587177/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com