Author Topic: custom summation?  (Read 220 times)

markn

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 4
    • View Profile
custom summation?
« on: August 24, 2024, 01:29:31 am »
I am going to try and explain this as best I can and provide an image that I hope will help explain it as well.  In each cell of my grid I have some custom html that actually has two different values in it.  If you look at the image you will see 10 /10% in row 5.  The second value is always static; it is set when the grid is loaded and cannot be changed by the user.  However, the first value can be changed. Using the example above a user could type in 37 and you would see 37/10%.  What I need help with is to sum all of those first values and display that total in another cell.  In the image example, if I have two values on the same row 10/10% and 17/20%, in one column I would sum the first values (27) and in another column I would have the second value sum (30).

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6296
    • View Profile
Re: custom summation?
« Reply #1 on: August 26, 2024, 05:42:42 pm »
Let's simplify it.

If the 1st value ( numerator ) is variable and 2nd value ( denominator ) is fixed, then you can keep numerator in the data and display denominator in column.render callback.

Code: [Select]
column.render = function(ui){
   return ui.cellData + "/10%";
}

This way only numerator would be shown in the editor when cell is edited.

And to compute values in a column depending upon corresponding values in other columns of same row, please use any of the following examples to set up column dependency.

https://paramquery.com/pro/demos/grid_formula

https://paramquery.com/pro/demos/rowtemplate