ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: mikep on August 18, 2021, 04:12:47 pm

Title: NaN in summary cell
Post 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: Re: NaN in summary cell
Post by: paramvir on August 19, 2021, 02:11:44 am
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
Title: Re: NaN in summary cell
Post by: mikep on August 19, 2021, 02:23:06 am
I don't understand how to use the metadata of the row to get the grouped sum. Could you elaborate?
Title: Re: NaN in summary cell
Post by: paramvir on August 19, 2021, 01:33:44 pm
metadata of row is used to identify the type of row ( normal, title, summary row )

Code: [Select]
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.
Title: Re: NaN in summary cell
Post by: mikep on August 19, 2021, 05:32:11 pm
I think I'm close, but still getting NaN on grouping.

https://jsfiddle.net/dep4bsL8/2/
Title: Re: NaN in summary cell
Post by: paramvir on August 20, 2021, 06:55:08 pm
I don't see colAP being used in your jsfiddle. Please check and correct logic of your jsfiddle.
Title: Re: NaN in summary cell
Post by: mikep on August 20, 2021, 07:45:49 pm
It's used. That's how the cells are getting colored red/orange/green. The only issue is the grouping column is NaN.
Title: Re: NaN in summary cell
Post by: paramvir on August 20, 2021, 10:15:20 pm
Please check this as a proof of concept: https://jsfiddle.net/2bvhnuaf/
Title: Re: NaN in summary cell
Post by: mikep on August 24, 2021, 07:42:04 pm
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.
Title: Re: NaN in summary cell
Post by: paramvir on August 25, 2021, 04:26:09 pm
group by column and aggregate columns can't be same.

"text" value returned in render callback is used only while rendering of current cell.
Title: Re: NaN in summary cell
Post by: mikep on August 25, 2021, 05:49:51 pm
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
Title: Re: NaN in summary cell
Post by: paramvir on August 25, 2021, 11:24:57 pm
Quote
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.

Quote
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.
Title: Re: NaN in summary cell
Post by: mikep on August 26, 2021, 12:16:37 am
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/
Title: Re: NaN in summary cell
Post by: paramvir on August 26, 2021, 06:40:09 pm
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.
Title: Re: NaN in summary cell
Post by: mikep on August 27, 2021, 12:42:29 am
sure.
https://jsfiddle.net/zc1hmarf/2/
Title: Re: NaN in summary cell
Post by: paramvir on August 27, 2021, 11:05:24 am
Thanks for the smaller jsfiddle.

There is NaN in summary of month1 column because the values in that column are not numbers.

Incorrect:
Code: [Select]
month1: '339938.0,red,hovertext',

Please correct them:
Code: [Select]
month1: 339938.0

Please also define dataType of month1 column as either 'float' or 'integer'.