Pivot Panel Error

Posted by: adisa.craig on 26 November 2024, 4:13 pm EST

    • Post Options:
    • Link

    Posted 26 November 2024, 4:13 pm EST

    When attempting to create a new pivotpanel, I am getting an error

    Uncaught TypeError: e.dh.addPivotView is not a function


    This error occurs when running below

    panelControl = new GC.Spread.Pivot.PivotPanel(pivotTable.name() + '_panel', pivotTable, $dialog.find("#pivotpanel")[0]);

    I tried updating to use below but in this case there is no error occurring but the panel area just shows blank

    panelControl = new GC.Spread.Pivot.PivotPanel(pivotTable.name() + '_panel', pivotTable, document.getElementById('#pivotpanel');
  • Posted 27 November 2024, 4:40 am EST

    Hi,

    It seems the panel is not rendering might be due to the element being incorrectly selected with document.getElementById(“#pivotpanel”). The document.getElementById method expects only the ID string of the element, without the # prefix. The # prefix is specific to CSS selectors (used in methods like querySelector) and is not required with getElementById.

    To resolve this, you can update your code as follows:
    
    var panel = new GC.Spread.Pivot.PivotPanel(
        pivotTable.name() + '_panel', 
        pivotTable, 
        document.getElementById("pivotpanel")
    );

    For further clarity, we’ve created a sample for your reference.

    If you encounter any further issues or need additional assistance, please don’t hesitate to reach out.

    Best regards,

    Ankit

    features_pivot-table_pivot-panel_overview_JavaScri.zip

  • Posted 27 November 2024, 11:24 am EST

    Hi Ankit, Sorry for the typo, but the error is showing up in the case where panelElement is selected as

    var panelElement = document.getElementById('pivotpanel');
    The error shown is

    Uncaught TypeError: t.dh.addPivotView is not a function
  • Posted 28 November 2024, 6:05 am EST

    Hi,

    We have been investigating your case but have not encountered the error Uncaught TypeError: t.dh.addPivotView is not a function in our testing. The following code snippet is working as expected on our end:

    var panelElement = document.getElementById('panel');  
    new GC.Spread.Pivot.PivotPanel("myPivotPanel", myPivotTable, panelElement);  

    To assist you further, we have created another simpler sample for your reference. Please feel free to review it. If the issue persists on your side, kindly share a reproducible sample so we can investigate the problem in greater detail.

    Reference:

    PivotPanel class API : https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotPanel#class-pivotpanel

    We look forward to your response.

    Best regards,

    Ankit

    features_pivot-table_pivot-panel_overview_JavaScript.zip

  • Posted 2 December 2024, 11:56 am EST

    Hi Ankit,

    Can you provide the above sample using jscodemine example as we are importing the spread library as such

    import * as GC from "@grapecity/spread-sheets"
    What would be the preferred way for importing the pivot table library?

  • Posted 3 December 2024, 7:33 am EST

    Hi,

    Regarding your query on “What would be the preferred way of importing the pivot table library?”, kindly make sure that you the import statements are correct i.e, the pivot addon import should be placed after the spread-sheets import. Following is correct import statement:

    import * as GC from "@mescius/spread-sheets";    // could use "@grapecity" also 
    import "@mescius/spread-sheets-pivot-addon";

    Here is the JSCodeMine Sample: https://jscodemine.mescius.io/share/kFfi3WX46EGaJFZLxghaBw/?defaultOpen={"OpenedFileName"%3A["%2Fsrc%2Fapp.js"]%2C"ActiveFile"%3A"%2Fsrc%2Fapp.js"}

    I have also attached an offline sample based on the same approach. If you still face the issue, kindly do share the sample with your implementation so that we could investigate at our end and could help you accordingly.

    Are you facing any issue with sharing the sample? If your sample involves confidential data, kindly you could create a new ticket on our private portal at: https://developer.mescius.com/my-account/my-support

    Regards,

    Ankit

    pivotpanel-PIVOTtable.zip

  • Posted 3 December 2024, 11:46 pm EST

    I was able to figure out the issue. It was a build error on our end. This can be marked as completed

Need extra support?

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

Learn More

Forum Channels