html - How to merge cell or make colspan on jquery-handsontable? -


i using handsontable make excel-like table. want have merged title on table. possible? or there other solution? thx.

<div id="example1" style="width: 400px; height: 300px; overflow: scroll"></div>  <script>             function mergecell(instance, td, row, col, prop, value, cellproperties) {               handsontable.textcell.renderer.apply(this, arguments);               td.colspan = 2;             }             var mydata = [               ["", "1", "2", "3", "4", "5", "6"],                  //i want merge first row using function 'mergecell'               ["year", "d", "n", "d", "n", "d", "n", "d", "n", "d", "n", "d", "n"],               ["2009", '', -11, 14, 13, 1, 2, 8, 13, -5, 9, 12, 0],               ["2010", '', 15, -12, 1, -5, '', 12, 3, -1, '', 12, 13],               ["2008", -5, '', 12, 13, -5, '', 12, 13, -4, '', 10, 3]];              $("#example1").handsontable({               data: mydata,               fixedrowstop: 2,               fixedcolumnsleft: 1,               contextmenu: true,               cells: function (row, col, prop) {                 var cellproperties = {};                   cellproperties.readonly = true;                                if (col != 0 && row === 0) {                   cellproperties.renderer = mergecell;                  }                 return cellproperties;               }             }); </script> 

i found answer question! function mergecell should called after other functions, if have them.

<div id="example1" style="width: 400px; height: 300px; overflow: scroll"></div>  <script>             function mergecell(instance, td, row, col, prop, value, cellproperties) {               handsontable.textcell.renderer.apply(this, arguments);               //td.colspan = 2; wrong, should :               td.setattribute("colspan", "2");             }             var mydata = [               ["", "1", "2", "3", "4", "5", "6", "", "", ""],                  //i dont know why should have columns               ["year", "d", "n", "d", "n", "d", "n", "d", "n", "d", "n", "d", "n"],               ["2009", '', -11, 14, 13, 1, 2, 8, 13, -5, 9, 12, 0],               ["2010", '', 15, -12, 1, -5, '', 12, 3, -1, '', 12, 13],               ["2008", -5, '', 12, 13, -5, '', 12, 13, -4, '', 10, 3]];              $("#example1").handsontable({               data: mydata,               fixedrowstop: 2,               fixedcolumnsleft: 1,               contextmenu: true,               cells: function (row, col, prop) {                 var cellproperties = {};                   cellproperties.readonly = true;                                if (col != 0 && row === 0) {                   cellproperties.renderer = mergecell;                  }                 return cellproperties;               }             }); </script> 

edit script load wrong data. @ last, cancelled making title cells merged.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

node.js - Node - Passport Auth - Authed Post Route hangs on form submission -

Does Firefox offer AppleScript support to get URL of windows? -