Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including Column Headers #1

Open
ElliotPsyIT opened this issue Jun 26, 2017 · 1 comment
Open

Including Column Headers #1

ElliotPsyIT opened this issue Jun 26, 2017 · 1 comment

Comments

@ElliotPsyIT
Copy link

ElliotPsyIT commented Jun 26, 2017

First, thank you @Atmos206 for the excellent work on ui-grid-custom-cell-select.

I'm using it in a project where I needed to include column headers by default. I simply patched the ui-grid-custom-cell-select directive for my purposes.

It's not a general solution since you might want to have an option to include headers or not (maybe a configurable provider) rather than include headers by default. And I did modify the copyData array assignment, which I probably shouldn't do.

In any case, I thought I'd briefly share the added code here FWIW. Perhaps someone might have a use for it as a quick and dirty option.

I'm a newbie, so any comments on the code or obvious bugs to be pointed out are welcome.

// copy headers from selected cells into copyData array,, then add the cells' data 
_scope.ugCustomSelect.copyData = createCopyHeaders(indexMap.col.start, indexMap.col.end)
_scope.ugCustomSelect.copyData += createCopyData(_scope.ugCustomSelect.selectedCells,

// copy headers fn
function createCopyHeaders(colStart, colEnd){
    var visibleCols = grid.renderContainers.body.renderedColumns;
    var numCols = colEnd - colStart;
    var columnHeaders = ''
    for (var ci = colStart; ci <= colEnd; ci++) {
        var currentCol = visibleCols[ci];
        columnHeaders += currentCol.displayName;
        if (ci !== colEnd) {
            columnHeaders += '\t';
        }
    }
    return columnHeaders + '\n';
}
@Atmos206
Copy link
Owner

Thanks for posting a workaround. Will look into solution implementation as time permits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants