Search code examples
kendo-uikendospreadsheet

Kendo spreadsheet rightmost column identification


I am new to Kendo world. And I need a help regarding the Kendo spreadsheet k-right class that's applied on the columns of spreadsheet.In my spreadsheet I have multiple tabs.each tabs can have different number of columns.But the last column is what I need as I need to bind a drop-down to the every row of that column for data selection. In my code I am using the class named k-spreadsheet-active-cell and k-right to identify the rightmost column position. But it's coming as undefined as k-right class is not getting applied. It's working fine for the tab which has max columns..for the lesser ones it's not getting applied.

Trying to read over Kendo site ,not getting any relevant info. Any help is hugely appreciated. Thanks.


Solution

  • You can handle the selectSheet event (documentation) to get the active spreadsheet when it changes.

    You can then get the spreadsheet's column definitions by calling the toJSON method (documentation).

    Finally you can get the last column definition by using some JavaScript (or jQuery) magic.

    Here's an example that you can use when initializing the spreadsheet component:

    selectSheet: function(arg) {
        var json = arg.sheet.toJSON();
        if (json.columns) {
            var lastColumn = json.columns[json.columns.length - 1];
            // do whatever it is you need to do with the lastColumn variable
        }
    }