We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Update TotalPrice value in edit dialog based on other field's value

Thread ID:

Created:

Updated:

Platform:

Replies:

129406 Mar 16,2017 02:38 AM Mar 20,2017 01:21 AM ASP.NET MVC 3
loading
Tags: Grid
Andrias Abadi
Asked On March 16, 2017 02:38 AM


Hi, I'm using the mvc grid to create invoice tables but I need the edit dialog to show the total price by multiplying the qty and unitprice when the value changes.
I can get the totalprice value displayed just fine using jsrender template after confirming insert dialog but not while in the dialog. I read some posts saying about LiveUpdate but I cant seem to find this one

Attachment: Syncfusion_Help_78ed95c9.rar

Venkatesh Ayothi Raman [Syncfusion]
Replied On March 17, 2017 07:15 AM

Hi Andrias, 
Thanks for contacting Syncfusion support. 
We have achieved your requirement using Dialog template editing. In that, we have rendered the dialog template edit form with expression column (total field) value while we change the data quantity and price Numeric text box then we must change the expression column value like as follows, 
Code example
@Grid 
 
@(Html.EJ().Grid<object>("DetailTemplate") 
        . . . 
    .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.DialogTemplate).DialogEditorTemplateID("#template"); }) 
            .Columns(col => 
            { 
                col.Field("SNO").HeaderText("SNO").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(90).Add(); 
                col.Field("quantity").HeaderText("quantity").Width(90).Add(); 
                col.Field("Price").HeaderText("Price").TextAlign(TextAlign.Right).Width(75).Add(); 
                col.HeaderText("total").Template("{{:quantity * Price}}").Width(85).Add();        
            }) 
 
                .ClientSideEvents(e => e.ActionComplete("actionComplete")) 
             
    ) 
 
@action complete 
  function actionComplete(args) { 
                //here we can bound the Numeric textbox control for qunatity and price column as well as define the change event for both 
                if ((args.requestType == "beginedit" || args.requestType == "add") && args.model.editSettings.editMode == "dialogtemplate") { 
 
                    $("#quantity").ejNumericTextbox({ value: $("#quantity").val(), change: "quantityChange" }); 
                     
                    $("#Price").ejNumericTextbox({ value: $("#Price").val(), change: "PriceChange" }); 
                } 
            } 
 
@quanity change event 
            function quantityChange(args) { 
                var price = +($("#Price").val()); // get the current value from input field 
                var quantity = +(args.value); 
                var total = price * quantity; 
                $("#Total").val(total); 
            } 
@price change event 
            function PriceChange(args) { 
                 
                var price = +(args.value); // get the current value from input field 
                var quantity = +($("#quantity").val()); 
                var total = price * quantity; 
                $("#Total").val(total); 
            } 
             

Screenshot
 

We have also prepared a sample for your convenience which can be download from following link. Please refer to the sample and Help documentation for your reference, 
Help documentation
Regards, 
Venkatesh Ayothiraman. 


Andrias Abadi
Replied On March 17, 2017 11:50 PM

Thanks, that solves the problem!

Venkatesh Ayothi Raman [Syncfusion]
Replied On March 20, 2017 01:21 AM

Hi Andrias, 
Thanks for the feedback. 
We are very happy to hear that your requirement is achieved. 
Regards, 
Venkatesh Ayothiraman. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;