2016-03-01 122 views
1

我使用kendo ui for html5 web应用程序。我只需要编辑一列(即单元),当它被更改时,金额列应该自动更新。例如:Kendo网格动态编辑

1单位= $ 10, 如果我将1个单位更改为5,则金额更改为$ 50。

我该如何做到这一点。

此前我发布了我的部分代码。现在我已经完成了telerik dojo的例子。 请看看这里

Working Example with Source code

更新#1:

演示看起来笨拙,我为此难过。点击第一页上带有号码的按钮,然后点击右上角的购物车图标。

此图像说明我想用该购物车页面做什么 Kendo datasource grid doubt 我该怎么做?

更新#2:

由于@RobertoDeLaParra 对于自己的解决方案,我走近一看完成。但我有一个新问题。

enter image description here

当我改变了股,合计并在编辑框中金额字段,也不会改变。

请看一看这个道场,

http://dojo.telerik.com/@varanjith/ePOrA/5

谢谢。

+0

你需要一个模型绑定到您的架构,并在仅使单元属性的模型可编辑 – raven

+0

@RobertoDeLaParra感谢您的回复我的朋友。但我使用两个数据源,1. Product&2.Cart。我在产品中选择的一个插入购物车数据源。所以在这种情况下,我如何绑定架构? 我保持模式模型为空。 –

+0

你能分享一个工作jsFiddler吗?我会看看它。 – raven

回答

2

嗨更改金额字段此:

{ 
    field: "Amount", 
    title: "Amount",     
    footerTemplate: "<div class='ra'>#= sum # </div>", 
    template: "<div class='ra'>#= Amount * Unit # </div>" 
    } 

和初始化cartGrid后补充一点:

var cartGrid = $("#CartGrid").data("kendoGrid"); 
cartGrid.bind("edit", function (e){ 
      //console.log(e.model); 
      var unitPrice = e.model.UnitPrice; 
      var unit = e.model.Unit; 
      //This code replace the input generated by kendo with our custom HTML 

      $("td[data-container-for='Amount']").html(unitPrice*unit); 
}); 
+0

嗨罗伯托,请看看我更新的问题。并再次感谢。 –

相关问题