Default squad in handson table

How do I make my handson table group available by default. It is open by default.

I have js and html code. fiddle

function getCarData() {
        return [ [ 'col1', "val2", "val3", "val4", "=SUM(E2:E4)" ],
                [ 4, 0, 3, 2, '=SUM(A2,B2,C2,D2)' ],
                [ 4, 0, 3, 2, '=SUM(A2,B2,C2,D2)' ],
                [ 4, 0, 3, 2, '=SUM(A2,B2,C2,D2)' ]
                ];
    }

    var container = document.getElementById('example1'), hot; 


    hot = new Handsontable(container, {
        data : getCarData(),
        colHeaders : true,
        rowHeaders : true,
        contextMenu : true,
        manualColumnResize: true,
         minSpareRows: 1,
          groups: [
            {
              rows: [1, 3]
            }
         ],
        formulas : true,
        columns: [ { type: 'numeric'},
                     { type: 'numeric'},{ type: 'numeric' },{ type: 'numeric' },{ type: 'text',readOnly: true}]

    });

      

+3


source to share


2 answers


While there aren't really any built-in functions to accomplish what you're looking for, there is a hacky workaround that I've used in the past. Take a look at this fiddle: http://jsfiddle.net/fk4uohjk/

As you can see, one of the groups is reset on page load. This is related to the following line:
hot.runHooks("beforeOnCellMouseDown", {"target": $("#htCollapseRowsFromLevel-1")[0]});



The hook beforeOnCellMouseDown

expects the mouse event to be the first parameter, but instead we can simply provide it with a dictionary with the target attribute set to the group's dom button element that corresponds to the group we want to collapse.

+2


source


Just add options to hot, which columns you don't want to resize ie: If you only want to resize the first three columns, you can do:

  manualRowResize: true,
    ...
    colWidths: [, , , x, x],
//x can be any colWidth number
   });

      



If you want the first and fourth columns

  manualRowResize: true,
    ...
    colWidths: [, x, x, , x],
   });

      

0


source







All Articles