我正在使用Handsontable创建一个可以在web和excel之间复制/粘贴的网格,我尝试使用下面的代码,它工作正常:
- var first = true;
- var exampleGrid = $("#exampleGrid");
- exampleGrid.handsontable({
- rowHeaders: true,colHeaders: true,stretchH: 'all',minSpareCols: 0,minSpareRows: 0,height: 600,columns: [
- { data: "Id",title: "ID",type: "text" },//'text' is default,you don't actually have to declare it
- { data: "Name",title: "Name",{ data: "DisplayColor",title: "Display Color",type: 'autocomplete',source: ["yellow","red","orange","green","blue","gray","black","white"]
- },{ data: "Description",title: "Description",type: 'text' },{ data: "IsDeleted",title: "Is Deleted",type: 'checkBox' }
- ],colWidths: [400,100,60,50,40,60],//can also be a number or a function
- contextMenu: false,});
现在我需要使用动态列创建Web网格,我尝试用下面的函数替换列列表,但它不起作用:@H_502_5@
- columns:
- function () {
- var cols = [];
- for (var i = 0; i < 1; i++) {
- var col = new Object();
- col.data = "Name";
- col.title = "Name" + i.toString();
- col.type = "text";
- cols[i] = col;
- }
- return cols;
- },
是否可以在Handsontable网格中创建动态列?怎么做?@H_502_5@