如何在handsontable中获取表头名称

时间:2013-07-25 05:28:33

标签: javascript jquery

我有一个像下面那样的小朋友

var $container = $("#example1");
$container.handsontable({
data: data1,
rowHeaders:true,
colHeaders: ["Sun","Mon","Tue","Wed","Thr","Fri","Sat"],
cols:13,
minSpareRows: 100
});
<div id="example1" class="dataTable" style="width: 1170px; height: 450px; 
overflow:scroll;"></div>

我可以访问表tr值

 var rowList = $("#example1").handsontable("getData");
 rowList = $.grep(rowList,function(array,index)
 {
  // here i can access values from first row  


 });

我需要访问标题“Sun”,“Mon”,“Tue”,“Wed”,“Thrs”,“Fri”,“Sat” 这该怎么做...?请帮助..

2 个答案:

答案 0 :(得分:2)

我编辑了这个:

 var rowHeaderList = $("#example1").handsontable("getRowHeader"); //for row headers 
 var colHeaderList = $("#example1").handsontable("getColHeader"); //for column headers

答案 1 :(得分:1)

只需使用:

hotInstance.getColHeader() 

来源:https://docs.handsontable.com/pro/5.0.2/Core.html#getColHeader