Author Topic: Dynamic Formulas with functions  (Read 2344 times)

mercury85

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 58
  • ASP.NET, VB.NET, MVC, JS, C#, VBA, SQL, MDX, DAX
    • View Profile
Dynamic Formulas with functions
« on: May 15, 2018, 01:40:24 pm »
.I am almost complete, but am on one last portion.  How could we create dynamic formulas..


                var formulaModel = ['r' + key, function (rd) { return rd.SERIES_TYPE === 'Forecast' ? rd[key]: undefined; }];

Trying this but no go so far...

Took the render off the colModel, and it looks like it is in teh render area...

  var colRenderObjCreate = {
                    title: key,
                    width: 150,
                    dataIndx: 'r' + key,
                    format: "##,###",
                    hidden: false,
                    nodrag: true,
                    align: "center",
                    cls: "date-col",
                    summary: {
                        type: "sum",
                        edit: false
                    },
                    render: function (ui) {
                    var rd = ui.rowData;
                        return (rd.SERIES_TYPE != 'Forecast' ?
                    pq.formatNumber(rd[key], ui.column.format) :
                    ui.formatVal);
                    }
                };


strangest thing is it is working only at the most child level...


Thank you
« Last Edit: May 15, 2018, 02:45:24 pm by mgregory85 »

mercury85

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 58
  • ASP.NET, VB.NET, MVC, JS, C#, VBA, SQL, MDX, DAX
    • View Profile
Re: Dynamic Formulas with functions
« Reply #1 on: May 15, 2018, 02:50:24 pm »
Stupid me....

had the following on the hidden column....

                summary: {
                        type: "sum",
                        edit: false
                    }


with that said, is there a way to just sum at the child level?
« Last Edit: May 15, 2018, 03:16:55 pm by mgregory85 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6307
    • View Profile
Re: Dynamic Formulas with functions
« Reply #2 on: May 15, 2018, 09:41:02 pm »
Quote
is there a way to just sum at the child level?

Please use groupModel.showSummary option. https://paramquery.com/pro/api#option-groupModel

e.g., if there is 3 level of grouping, summary can be shown in 3rd level only by

Code: [Select]
  showSummary: [ false, false, true ]