Not able to copy data from wijmo flexgrid if column is created dynamically

Posted by: vinaybietpratap on 17 March 2024, 9:47 am EST

  • Posted 17 March 2024, 9:47 am EST - Updated 18 March 2024, 1:38 am EST

    Hi, I am trying to copy data from a custom inserted column in Wijmo Flexgrid. Custom column comprises of two span. For auto generated column it is working fine but not incase of custom column. For me column name is ‘DC1710398712981’ which i am trying to copy the data. I have attached two screenshots. Let me know if any further details are needed. Using “@grapecity/wijmo.angular2.all”: “5.20203.766” version.

  • Posted 18 March 2024, 9:24 am EST

    Hi,

    You can handle the copying event on Flexgrid, to execute your custom copy function, You can achieve that by using Wijmo’s clipboard. Please refer to the code snippet and sample link below for reference:

      theGrid.copying.addHandler((s, e) => {
        //cancel default behavior
        e.cancel = true;
        var copyString = '',
          newLine = '',
          tab = '';
        for (var r = e.range.topRow; r <= e.range.bottomRow; r++) {
          if (s.rows[r].visible) {
            for (var c = e.range.leftCol; c <= e.range.rightCol; c++) {
              var col = s.columns[c];
              if (col.visible) {
                newLine = c == e.range.rightCol ? '\n' : '';
                tab = c == e.range.rightCol ? '' : '\t';
                //get selected cell data
                var selectedCellData = s.getCellData(r, c);
                selectedCellData =
                  selectedCellData == null || undefined ? '' : selectedCellData;
                if (col.binding === 'change') {
                  selectedCellData = e.panel.getCellElement(r, c).innerText;
                }
                copyString += selectedCellData + tab + newLine;
              }
            }
            //copy data into Clipboard
            wijmo.Clipboard.copy(copyString);
          }
        }
      });

    sample link: https://stackblitz.com/edit/js-cympzz?file=index.js

    You can modify the copy logic as per your requirements. In case you need further assistance then please let us know.

    Regards

Need extra support?

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

Learn More

Forum Channels