简体   繁体   中英

Kendo grid dynamic edit

i'm using kendo ui for html5 web app. and i need to edit only one column (ie, Unit) and when it is changed, the Amount column should update automatically. for example:

1 unit = $10, if i change 1 unit to 5, then amount changes to $50.

How can i achieve this.

Previously I posted a part of my code. now i have done a telerik dojo example. please take a look here

Working Example with Source code

Update #1:

The demo looks clumsy, i'm sorry for that. click the button with number in first page, then click the cart icon on the top right corner.

This image explains what i want to do with that cart page Kendo数据源网格怀疑 How can i do that?

Update #2:

Thanks to @RobertoDeLaParra For his solution, i came closer completing. but i have a new issue.

在此处输入图片说明

When i change the Unit, the aggregate and the Amount field in edit box, doesn't change.

Please take a look at this dojo,

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

Thank you.

Hi change your amount field for this:

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

and after initializing the cartGrid add this:

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);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM