Wijmo formatItem: How to convert olap grid content to anchor tag?

Posted by: hgarg261 on 27 May 2022, 9:59 pm EST

    • Post Options:
    • Link

    Posted 27 May 2022, 9:59 pm EST

    I have olap/pivot grid. I need to convert content of one the column in grid to anchor tag.

    I am using formatItem Event for that. Using following code, but it converting column header to anchor tag, not to content of that column and also content didn’t show in grid.

    
                let e = wijmoEvents.e, s = wijmoEvents.s;
                let ng = s.engine;
     if(true)
                  {
                    if (ng.rowFields[ wijmoEvents.e.col % ng.rowFields.length].header == 'Duplicate Group'){
                     wijmoEvents.e.cell.innerHTML = "<a href='https://www.w3schools.com' >"+ wijmoEvents.e.cell.innerHTML+"</a>";
                    }
                  }
    
    

    Any idea what I am missing?

  • Posted 29 May 2022, 8:22 pm EST

    Hello,

    You may refer to apply the condition to check if the cellType is ColumnHeader or Cell, depending upon your requirement you can check the cellType on which you want to apply the formatting. Please refer to the code snippet and sample link below demonstrating the correct way to use the formatItem:

    
      pivotGrid.formatItem.addHandler((s, e) => {
        if (e.panel.cellType == wjGrid.CellType.Cell && e.col == 1) {
          e.cell.innerHTML =
            "<a href='https://www.grapecity.com/wijmo/demos/OLAP/PivotGrid/CustomizeFieldcells/Sparklines/purejs' >" +
            e.cell.innerHTML +
            '</a>';
        }
      });
    
    

    Sample link: https://stackblitz.com/edit/js-nfw1eg?file=index.js

    API link: https://www.grapecity.com/wijmo/api/enums/wijmo_grid.celltype.html

    Regards

  • Posted 2 September 2022, 12:23 am EST

    Thank you so much, It worked

Need extra support?

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

Learn More

Forum Channels