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.

is there a specific cell event ( CellEditEnd Event(?) ) in Grid control?

Thread ID:

Created:

Updated:

Platform:

Replies:

132535 Sep 7,2017 01:16 AM Sep 8,2017 01:44 AM ASP.NET MVC 1
loading
Tags: Grid
Dongil Shin
Asked On September 7, 2017 01:16 AM

Hi I'm testing on Syncfusion mvc editable grid.

Each row has birthdate and age cells.

Once I enter the birth date value, I then tab across to the Age cell.
I want the Age cell value to be calculated automatically.
Is there an event I can use that allows me to fire it so that when I move the cursor to the Age field, the age value is calculated based on the birth date?

Please give me some idea.

Thank you in advance!
Kind Regards

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On September 8, 2017 01:44 AM

Hi Dongil, 
 
Thanks for contacting Syncfusion Support.  
 
We can update the other cell values while updating the current cell value in the batch editing mode using the CellSave event and setCellValue method. Refer to the following code example and API References.  
 
@(Html.EJ().Grid<object>("Grid") 
           .EditSettings(edit => 
            { 
                     . .  
                     . . . 
                edit.EditMode(EditMode.Batch); 
            }) 
                 . .  
        .ClientSideEvents(events => events.CellSave("onCellSave")) 
        .Columns(col => 
            { 
                col.Field("EmployeeID").IsPrimaryKey(true).HeaderText("Employee ID").Add(); 
                . . .  
                      . ..  
                col.Field("BirthDate").HeaderText("Birth Date").Format("{0:MM/dd/yyyy}").Add(); 
                col.Field("Age").HeaderText("Age").Add(); 
            }) 
) 
 
<script type="text/javascript"> 
 
    function onCellSave(args) { 
        if (args.columnName == "BirthDate") { 
            var age = calculateAge(args.value); 
            var inx = this.getIndexByRow($(args.cell).closest("tr")); 
            this.setCellValue(inx, "Age", age); 
        } 
    } 
    function calculateAge(birthDate) { 
        birthDate = new Date(birthDate); 
        otherDate = new Date(); 
 
        var years = (otherDate.getFullYear() - birthDate.getFullYear()); 
 
        if (otherDate.getMonth() < birthDate.getMonth() || 
            otherDate.getMonth() == birthDate.getMonth() && otherDate.getDate() < birthDate.getDate()) { 
            years--; 
        } 
        return years; 
    } 
</script> 
 
 
We have prepared a sample that can be downloaded from the following location.  
 
 
For calculating the Age from the given date, please follow this article.  
 
 
Regards,  
Seeni Sakthi Kumar S. 


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.

;