【问题标题】:Handsontable columns attribute prevents data displayHandsontable 列属性阻止数据显示
【发布时间】:2016-03-01 10:46:05
【问题描述】:

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

以下代码在没有列属性的情况下可以正常工作..

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。

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

【问题讨论】:

    标签: handsontable


    【解决方案1】:

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

      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/

    【讨论】:

      猜你喜欢
      • 2015-07-15
      • 1970-01-01
      • 1970-01-01
      • 2018-02-24
      • 2011-04-04
      • 2017-09-13
      • 1970-01-01
      • 1970-01-01
      • 2016-06-13
      相关资源
      最近更新 更多