Handsontable columns属性可防止数据显示

时间:2015-11-27 09:12:18

标签: handsontable

根据文档here,我尝试在表格中添加一个下拉列表。

以下代码在没有columns属性的情况下工作正常。

function getData(obj){
  $('body')
    .append('<div id="Hot" class="hot handsontable htColumnHeaders"></div>');
  var container = document.getElementById('Hot'),hot;
  hot2 = new Handsontable(container, {
    data:[{
          "_____DELETE_____" :"No"
           ,"CMPCODE" :"H54"
           ,"CODE" :"666"
           ,"IFRS_HIERARCHY" :"Goodwill"
         }]
    ,colHeaders: ["_____DELETE_____","CMPCODE","CODE","IFRS_Hierarchy"]
    /* the line below prevents data being displayed */
    ,columns: [{type: 'dropdown',source: ['No','Yes']},{},{},{}]
  });
};

它不是空值({}),因为它不能完全用于_____DELETE_____列。

我必须遗漏一些明显的东西,但看不到它!我正在使用.js / .css文件的v0.20.1。

编辑 - 创建了一个小提琴:http://jsfiddle.net/rawfocus/22ubvxaa/

1 个答案:

答案 0 :(得分:0)

破解它。每个元素都需要引用它引用的实际列,例如:

  var container = document.getElementById('example1'),hot;
  hot2 = new Handsontable(container, {
    data:[{
          "_____DELETE_____" :"No"
           ,"CMPCODE" :"H54"
           ,"CODE" :"666"
           ,"IFRS_HIERARCHY" :"Goodwill"
         }]
    ,colHeaders: ["_____DELETE_____","CMPCODE","CODE","IFRS_Hierarchy"]
    /* the line below is working now :-)  */
    ,columns: [
        {data:"_____DELETE_____"
             ,type:'dropdown',source: ["No",'Yes']}
         ,{data:"CMPCODE"}
         ,{data:"CODE"}
         ,{data:"IFRS_HIERARCHY"}
    ]
  });

小提琴:http://jsfiddle.net/rawfocus/22ubvxaa/2/

相关问题