ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: mikep on June 25, 2024, 05:09:48 pm
-
I need to format a cell as currency or integer, based on the value of another column in the row.
I want to maintain the functionality that when the cell is selected to edit, the "$" is removed when editing the cell.
How would I do that?
-
you would use the column.render to conditionally format a cell depending on the value of another column.
render: function( ui ){
if(ui.rowData.another_column_dataIndx == some_value ){
//format as currency.
}
else{
//format as number.
}
}
and you can use the formatNumber for formatting: https://paramquery.com/pro/api#method-formatNumber
-
Thanks, I got that far. What do I put for //format as currency?
"format: '$#,###' " is what I'm looking for, but this seems to only work when defining the column, but not during render. I need it during render, since its conditional based on the row.
-
You don't need to use column.format but call pq.formatNumber method with required format as parameter and return the formatted string from column.rernder
-
Thank you. Can you correct this. the 2 options below dont work.
render: function( ui ){
if(ui.rowData.another_column_dataIndx == some_value ){
//format as currency.
return { pq.formatNumber(1200, "$#,####") }
}
else{
//format as number.
pq.formatNumber(1200, "#,####")
}
}
-
You need to substitute pseudo code with actual conditions i.e, another_column_dataIndx is to be replaced with actual dataIndx
and you also need to return the formatted value in case of number.
-
I understand that. I need the syntax to do the actual formatting in the render, the below 2 lines don't work.
return { pq.formatNumber(1200, "$#,####") }
pq.formatNumber(1200, "#,####")
-
That would be
return pq.formatNumber(1200, "#,####");
-
Thank you. I also need to format the summary cell. I'm always getting the currency format
-
Same logic applies to summary cells. Please share a jsfiddle if facing issues.