ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

customTreeAggregationFinalizerFn How to get current tree node ?

Open doctorsender opened this issue 10 years ago • 2 comments

 customTreeAggregationFinalizerFn : function (aggregation) {  

aggregation.rendered = aggregation.value;
}

I just need access to other column aggregation value from this function environment.

I need do something like that:

customTreeAggregationFinalizerFn : function (aggregation) {
aggregation.rendered = row.column["views"].getAgreggationValue() / row.column["amount"].getAgreggationValue() ;
}

But I don't know how to get current row from treeNode or anywhere

doctorsender avatar Mar 21 '16 15:03 doctorsender

The treeBase documentation may help you http://ui-grid.info/docs/#/api/ui.grid.treeBase, particularly the documentation for tree: http://ui-grid.info/docs/#/api/ui.grid.treeBase.grid:treeBase.

Having said this, it looks to me on first glance that the row information is passed into treeAggregationFunctions but not the finalizer. It may be available through this or another such variable - check in your debugger.

PaulL1 avatar Mar 21 '16 18:03 PaulL1

I have a solution, but I don't know if its the best..

customTreeAggregationFinalizerFn : function (aggregation) {
aggregation.rendered = aggregation.value2 * 100 / aggregation.value1
}

customTreeAggregationFn : function( aggregation, fieldValue, numValue, row ) { if(row.entity.A){ if(!aggregation.value1){ aggregation.value1 = parseFloat(row.entity.A); aggregation.value2 = parseFloat(row.entity.B); } else{ aggregation.value1 += parseFloat(row.entity.A);
aggregation.value2 += parseFloat(row.entity.B) ; }
}
}

I just add a personalized aggregation values to aggregation object. Because I couldn't found te ui-grid aggregation value from treeNode

doctorsender avatar Mar 22 '16 12:03 doctorsender