How to update / force render a custom panel

WebViewer Version: 8.2.0-20220119

Are you using the WebViewer server? No

I’m created a custom panel using setCustomPanel and activated it with setActiveLeftPanel. The panel should show information about the document and the applied modifcations. After the document was changed I need to update the information inside the panel. How is it possible to enforce the panel to get rendered again with the current informations? Calling setActiveLeftPanel won’t re-render the panel again.

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hello,

Thank you for contacting WebViewer’s support. We currently don’t have an API for forcing re rendering of the custom panel but you can achieve this by quickly disabling and enabling it like the following

Webviewer({}, document.getElementById('viewer')).then(instance => {
  let count = 0;

  const renderFunc = () => {
    const div = document.createElement('div');
    const div2 = document.createElement('div');

    div.appendChild(div2)
    div2.innerHTML = `Hello World ${count}`;

    const btn = document.createElement("button");
    btn.innerHTML = "count";
    btn.type = "submit";
    btn.name = "formBtn";
    btn.onclick = function () {
      count++;
      instance.disableElement('customPanel')
      instance.enableElement('customPanel')
      instance.setActiveLeftPanel('customPanel')
    };
    div.appendChild(btn);
    return div;
  }

  const myCustomPanel = {
    tab:{
      dataElement: 'customPanelTab',
      title: 'customPanelTab',
      img: 'https://www.pdftron.com/favicon-32x32.png',
    },
    panel: {
      dataElement: 'customPanel',
      render: renderFunc
    }
  };

  instance.setCustomPanel(myCustomPanel);
});

Please let me know if the above helps or if you want me to clarify something

Best Regards,

Andrew Yip
Software Developer
PDFTron Systems, Inc.
www.pdftron.com