문제

Is there any method to get the column number from the column name?

I can only retrieve the column name, and I need the column number for getCellMeta.

Thanks

도움이 되었습니까?

해결책

Made this function that solved my problem:

function GetColFromName(name)
{
    var n_cols  =   $editorTableContainer.handsontable('countCols');
    var i       =   1;     

    for (i=1; i<=n_cols; i++)
    {
        if (name.toLowerCase() == $editorTableContainer.handsontable('getColHeader', i).toLowerCase()) {
            return i;
        }
    }
    return -1; //return -1 if nothing can be found
}

다른 팁

This is almost what I required but not quite as I needed the column prop. I couldn't find the answer anywhere so thought I would add this to the thread that helped me.

instead of using 'getColHeader' use 'colToProp'.

Use propToCol("Column Name"). This returns the column's index.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top