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. Image for the cookie policy date

how to get the sum for certain column data in treegrid?


In treegrid, I have a column "Percent", in which user can input number. I'd like to calculate the total percent each time user finish entering number.
In that way, I can ensure the total number input for the column will not be greater than 100.
How do I get the total sum for column "Percent"?


3 Replies

MK Mahalakshmi Karthikeyan Syncfusion Team October 15, 2015 10:13 AM UTC

Hi Harry,

We can get the sum of particular column after the editing with the help of “EndEdit” client side event. Please refer the below code example for details.



.Columns(co => {




ClientSideEvents(eve => {




<script type = "text/javascript" >

function endedit(args) {

       var percentValue = parseInt(args.data.PercentDone);

       if (args.columnName == "PercentDone") {

              var treeObj = $("#TreeGridContainer").data("ejTreeGrid");

              var records = treeObj.model.flatRecords;

              for (var i = 0; i < records.length; i++) {

                     if (!ej.isNullOrUndefined(records[i].PercentDone) && records[i].index != args.data.index) percentValue += records[i].PercentDone;


              if (percentValue > 100) args.cancel = true

              alert("Total of Percent Column is" + percentValue);




Here we have displayed the sum of percent column in alert box, and cancelled the editing if the entered value makes the sum greater than 100 using “args.cancel=true”.

Can you please share us more details about the percentage value you have considered as 100% to convert the sum value to percentage?

We have also prepared a sample based on this and you can find the sample under the following location.

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/SumThePercentage705145007


Mahalakshmi K.

HZ Harry Zheng October 15, 2015 06:10 PM UTC

Hi Mahalakshmi,

Thank you for the solution. It's working!


MK Mahalakshmi Karthikeyan Syncfusion Team October 16, 2015 05:09 AM UTC

Hi Harry,

Thanks for the update.

Please let us know if you need further assistance on this.


Mahalakshmi K.

Live Chat Icon For mobile
Up arrow icon