175
Views
3
Comments
Solved
[OutSystems Data Grid Web] Exporting links
Question
outsystems-data-grid-web
Web icon
Forge asset by OutSystems

Hey guys,

When using the export function it seems to be exporting my URL, instead of the title which is being displayed (I'm using title to display a nice dynamic textual value instead of the url).

Any idea's in how I can achieve getting the display value only instead of the full url when using an export?

2017-12-13 08-27-28
Joey Moree
Solution

I have updated the exportExcelFromContextMenu function to:

exportExcelFromContextMenu: function(gridId) {
        // create book with current view
        var flexGrid = GridOS.ComponentUtils.getGridObjectById(gridId).grid;
        var book = wijmo.grid.xlsx.FlexGridXlsxConverter.save(flexGrid, {
            includeColumnHeaders: true,
            formatItem: function(args) {
                var cellVal = args.xlsxCell;
                if($(args.cell).children('a').length){
                    cellVal.value = $(args.cell).children('a').first().text();
                }
            }
        });
        book.sheets[0].name = 'export';
        // save the book
        book.save("export.xlsx");
    }

This will allow links to be exported using the display value (you can set title to be used as a display value).

I have not done the csv version yet... there's not a formatItem function I could use there I'm afraid.

Perhaps Outsystems R&D can include this in the original component?

2017-12-13 08-27-28
Joey Moree

I got this working myself, but I had to create a clone of the component in order to add a bit of code in the export excel function.

Using the formatitem event on the xlsx save class.

2017-12-13 08-27-28
Joey Moree
Solution

I have updated the exportExcelFromContextMenu function to:

exportExcelFromContextMenu: function(gridId) {
        // create book with current view
        var flexGrid = GridOS.ComponentUtils.getGridObjectById(gridId).grid;
        var book = wijmo.grid.xlsx.FlexGridXlsxConverter.save(flexGrid, {
            includeColumnHeaders: true,
            formatItem: function(args) {
                var cellVal = args.xlsxCell;
                if($(args.cell).children('a').length){
                    cellVal.value = $(args.cell).children('a').first().text();
                }
            }
        });
        book.sheets[0].name = 'export';
        // save the book
        book.save("export.xlsx");
    }

This will allow links to be exported using the display value (you can set title to be used as a display value).

I have not done the csv version yet... there's not a formatItem function I could use there I'm afraid.

Perhaps Outsystems R&D can include this in the original component?

2018-01-16 15-07-33
Rita Dias
Staff

Hey Joey!


We'll definitely have a look at this and implement it.

Thank you so much for all the help with this and all of your answers and solutions on the other threads :) 


Cheers!


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.