getAggregateValue not working after loading the viewDefinition on pivotEngine

Posted by: bruno.santos on 16 November 2023, 10:03 am EST

    • Post Options:
    • Link

    Posted 16 November 2023, 10:03 am EST - Updated 16 November 2023, 10:08 am EST

    Hello,

    I am working with PivotEngine and PivotGrid with the option to save and load the viewDefinition. It is working, except with the fields that use a function to define its value (get-aggregate-value on the c1-pivot-field). The problem is that, after loading the viewDefinition, the values are not calculated (apparently it considers the aggregate type as the value).

    The pivot engine definition:

    The loading function:

    I would like to know if there is some way to reload the values. Force it to call the function after loading the viewDefinition.

  • Posted 17 November 2023, 5:20 am EST

    Hi,

    We are sorry but we are unable to replicate the issue. Could you please share a working sample project that replcates the issue? you may also refer to the following sample and update it to replicate the issue so that we can investigate it further and help you accordingly.

    Regards,

    Avinash

    C1MvcOlap_sample.zip

  • Posted 22 November 2023, 2:00 pm EST

    Hi,

    I made the necessary changes to replicate my issue. When opening the first time, there will be 2 calculated columns (F1 and F2). Also, the viewDefinition will be saved on the local storage. Reloading the page will load the view definition and the calculated columns will show a different value. Basically, it does not call the function that define the value for these columns.

    C1MvcOlap_sample2.7z

  • Posted 25 November 2023, 3:15 pm EST

    Hello Bruno,

    Thank you for sharing the modified sample. We were able to replicate the issue at our end. In the further investigation, we found that the issue is expected as the getAggregateValue is not defined in viewDefinition and as the viewDefinition is set, the default setting done from MVC code would be avoided. That is why, on loading the viewDefinition, it shows 0 or different value based on internal calculation as per property setting.

    To view the correct values, we need to update the loadViewDefinition method as follows:

       function loadViewDefinition() {
           let ng = c1.getService('indexEngine');
           if (ng && localStorage.viewDefinition) {
               ng.viewDefinition = localStorage.viewDefinition;
               var f1 = ng.fields.getField("F1");
               f1.getAggregateValue = row => function1(row);
               var f2 = ng.fields.getField("F2");
               f2.getAggregateValue = row => function2(row);
               ng.refresh();
           }
    
       }

    Regards,

    Manish Gupta

  • Posted 28 November 2023, 3:46 pm EST

    Thank you for the solution.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels