3.0.5

2.25.2 copy via ctrl-c contents of my grid into excel

How would I do the following: Just upgraded to 2.5.2 and want to do the following (ie copy all rows and cells in a grid via Ctrl-C and paste into Excel.

In the history notes on this site it states the following:

The grid now supports clipboard copy/paste - copy selected cells/rows with Ctrl-C and paste into another application (Excel, Word etc.)

is there a chunk of code on how to do this.

thanks.

jeff

Jeff C
September 4,
By default the grid copies the current selection (rows or cells, depending on the selection mode). You can change the default behavior if you overwrite the getSelectedText method (/source/lib/grid/control.js, line 469)

obj.getSelectedText = function(){
        var c, r, a, text = [];
        var cols = this.getSelectedColumns();
        var rows = this.getSelectedRows();
        if (this.getCurrentSelection() == "row"){
            cols = [];
            var count = this.getColumnCount();
            var indices = this.getColumnIndices();
            for (c=0; c<count; c++){
                cols[c] = indices ? indices[c] : c;
            }
        }
        for (r=0; r<rows.length; r++){
            a = [];
            for (c=0; c<cols.length; c++){
                a[c] = this.getCellText(cols[c], rows[r]);
            }
            text[r] = a.join("\t");
        }
        return text.join("\r\n");
    };
Alex (ActiveWidgets)
September 5,
Thanks alex. perfect.
Jeff c
October 2,

This topic is archived.

See also:


Back to support forum