Search code examples
handsontable

handsontable is it possible to have comboboxes (dropdowns) on a row rather than a column?


is it possible to have comboboxes (dropdowns) on a row rather than a column?

all the examples I've found talk about columns only, e.g. http://docs.handsontable.com/0.15.0-beta6/demo-dropdown.html

I need a row of editable comboboxes instead, does anyone have any examples of how do achieve this, if it is even possible?


Solution

  • @ZekeDroid pointed me in the right direction to the answer for what I actually asked. Adding the code here so you don't have to waste time learning to do it for yourself.

    function getCarData() { return [ ['dog', 'dog', 'dog','dog'], ["Something", 2013, "blue", "blue"], ["Else", 2014, "yellow", "black"], ["Here", 2015, "white", "gray"]]; }

    var
    container = document.getElementById('example1'),
        hot;
    
    hot = new Handsontable(container, {
        data: getCarData(),
        colHeaders: ['Car', 'Year', 'Chassis color', 'Bumper color'],
        cells: function (row, col, prop) {
            var cellProperties = {};
    
            if (row === 0) {
                cellProperties.type = 'dropdown';
                cellProperties.source = ['yellow', 'dog', 'cat'];
            }
    
            return cellProperties;
        }
    });