ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: mikep on August 18, 2021, 04:12:47 pm
-
After implementing the {style, text, attribute} for the cell, when I group on another column, the grouping row for this cell (the {text} of the render is a number) now shows NaN, rather than the sum. How can I get the sum to display, now that I'm implementing the render method for this column? This is how the column is defined:
{ title: ap, editable: canEdit, dataIndx: key, datatype: "float", format: nbrFormat, summary: { type: "sum" }, align: "right" }
return {
style: 'background-color:' + color,
text: 111,
attr: 'title="'+ hovertext + '"'
}
-
title row has pq_gtitle metadata and summary row has pq_gsummary metadata so they can be excluded using if condition.
https://paramquery.com/pro/tutorial#topic-metadata
-
I don't understand how to use the metadata of the row to get the grouped sum. Could you elaborate?
-
metadata of row is used to identify the type of row ( normal, title, summary row )
if ( rd.pq_gtitle || rd.pq_gsummary ){ //title row or summary row.
//let the grid do its own rendering
}
else{
return {
text: xyz...
style: xyz...
attr: xyz...
}
}
where rd is row data.
-
I think I'm close, but still getting NaN on grouping.
https://jsfiddle.net/dep4bsL8/2/
-
I don't see colAP being used in your jsfiddle. Please check and correct logic of your jsfiddle.
-
It's used. That's how the cells are getting colored red/orange/green. The only issue is the grouping column is NaN.
-
Please check this as a proof of concept: https://jsfiddle.net/2bvhnuaf/
-
Thank you for that. Is there any way to get the group by column to sum, based on the parsed value that is used in the "text" attribute, rather than referencing another column for this? I don't want to return another column in the query for complexity reasons.
-
group by column and aggregate columns can't be same.
"text" value returned in render callback is used only while rendering of current cell.
-
thanks for clarification. So to re-state, is there any way to have the aggregate column sum based on the "text" value returned in render callback. Is there any other option, rather than returning another column with only the "text" value as the dataIndx
-
is there any way to have the aggregate column sum based on the "text" value returned in render callback.
render callback is called for every cell including aggregate column sum, so yes "text" value can be used even in summary cells.
Is there any other option, rather than returning another column with only the "text" value as the dataIndx
Sorry your question is not clear. please share a simple use case scenario.
-
Here's my JS fiddle from before. The proof of concept you sent was using another column to create the sum in the aggregate column. I want to sum the column based on the text value I parsed, rather than see NaN in Month1.
https://jsfiddle.net/dep4bsL8/2/
-
can you please share a smaller jsfiddle by keeping the code pertaining to issue only and removing all other irrelevant code so that I can better understand the issue faced by you.
Appreciate your understanding.
-
sure.
https://jsfiddle.net/zc1hmarf/2/
-
Thanks for the smaller jsfiddle.
There is NaN in summary of month1 column because the values in that column are not numbers.
Incorrect:
month1: '339938.0,red,hovertext',
Please correct them:
month1: 339938.0
Please also define dataType of month1 column as either 'float' or 'integer'.