For one of the columns in a ‘grouped’ grid I want to show information which does not depend on value in that column. So I don’t want to use something like #title or #stat_max but instead ‘#my own calculation’.
Please can you tell me if there is any way of doing that using forEachRowInGroup function? An example would be useful.
You may try to use the customGroupFormat method to redefine the text of group-row: docs.dhtmlx.com/doku.php?id=dhtm … grouping&s[]=customGroupFormat#math_operations_in_group-by_mode
Or you may try to create your own custom calculation.
Here is the examples of the basic values:
but nothing appeared in that particular column. I then commented out the prototype function but left the #test_group in the groupBy and the system didn’t complain. This suggests that if it finds anything other than the pre-defined functions it ignores it.
By the way I’m currently on Version 3.0 Pro.
Please can you tell me what I might be doing wrong.
Thanks for the info but I worked that out as well. But it still doesn’t help me because I want to return the total value for all rows for a ‘hidden’ column. However I don’t have access to the row id as the Group Stats are being created so I’m still stuck. Any ideas on how I can access other cells from the rows in that Group?
I’ve looked at forEachRowInGroup function but that requires a group ‘name’ which I also don’t have access to whilst the Stats are being built.
Please can you show me an example of how forEachRowInGroup function can be used to set the Group Header Row. Perhaps once I understand that then I will be able to work forward.
using the custom shortcut:
mygrid._g_stat_test_group = function (tag, index, c) {
return “ABC”;
};
tag - the number displaying in the group header (the final result of the math).
index - the value of a current cell (iterating through all rows)
c - counter of the rows in the group.
So, for example, to calculate the sum of the values in the group you need:
Thank you for explaining what each of the variables are. That was very useful.
I’m trying to find a way of using the rest of the row’s information in calculating the Group Header line. Please will you give me an example of how forEachRowInGroup function can be used to set the Group Header line.
Using the forEachRowInGroup() method allows to operate withe rows in the group.
The method should be called from a customGroupFormat function.
mygrid.customGroupFormat=function(name,count){
mygrid.forEachRowInGroup(name,function(id){
console.log(name) // name of the group
console.log(id) // row id
var val=mygrid.cells(id,4).getValue()
console.log(val) // value of a needed cell
});
return name+", some logic"+mygrid.groupStat(name,3,"stat_test_group");
}
Please may I re-open this topic again. I am still working with V3.0 Prof. I now have a more complex requirement. My grid data consists of rows of bookings for a catering company. Each row shows the date of the booking and the Client Name + a hidden column showing the number of diners. The remaining are a variable number of columns depending on the Cooking Locations that exist during that period. Any one booking can only be allocated to one Cooking Location. So in a single row:
the Date column is always filled in
the Client Name is always filled in.
the hidden column of number of diners is always filled in
then out of the remaining columns which represent Cooking Locations all the columns are blank EXCEPT for one which contains some ‘data’ and represents the Cooking Location for that booking.
I want to Group on the Date column but for each Group I want to show the total of diners from the hidden column for the appropriate Cooking Location.
Here is some sample data: = hidden column
Date | Name | Diners | Ckg Loc A | Ckg Loc B
13/1/18 | Client A | <20> | data |
13/1/18 | Client B | <25> | data |
13/1/18 | Client C | <10> | | data
So in my group header I want to show a value of 45 under Ckg Loc A and a value of 10 under Ckg Loc B.
Please can you tell me if this is at all possible and if it is then how I would code it.
Thanks very much for your response Sematik. What you are suggesting will work for the column containing the #title. However I want to put the number as a #stat in the appropriate column.
Unfortunately the inbuilt #stat functions don’t have the facility to iterate through each row in the group and use ‘other’ fields of that row before returning a value.
I don’t know whether this is possible but if in the future you could allow for the inbuilt #stat functions to iterate through each row in the group and use ‘other’ fields of that row BEFORE returning a value then I would be able to achieve what I need.
I have changed my apps design so that I can use one of the inbuilt #stat functions for the moment but it is not a perfect situation.