您好,按照您的思路,我这边实现了一个Demo,您参考一下,代码如下:
- window.onload = function () {
- GC.Spread.Common.CultureManager.culture("zh-cn");
- var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 1 });
- spread.suspendPaint();
- var sheet = spread.getActiveSheet();
- var spreadNS = GC.Spread.Sheets;
- var dataSource = {records: [{f1:true, f2: "name1", f3:"desc1"},{f1:false, f2: "name2", f3:"desc2"},{f1:true, f2: "name3", f3:"desc3"}]};
- var dataSource1 = new spreadNS.Bindings.CellBindingSource(dataSource);
- var table = sheet.tables.add("tableRecords", 0, 0, 3, 3, spreadNS.Tables.TableThemes.light6);
- table.autoGenerateColumns(false);
- var tableColumn0 = new spreadNS.Tables.TableColumn();
- tableColumn0.name("选择");
- tableColumn0.dataField("f1");
- var tableColumn1 = new spreadNS.Tables.TableColumn();
- tableColumn1.name("名称");
- tableColumn1.dataField("f2");
- var tableColumn2 = new spreadNS.Tables.TableColumn();
- tableColumn2.name("描述");
- tableColumn2.dataField("f3");
- table.bindColumns([tableColumn0,tableColumn1, tableColumn2]);
- table.bindingPath("records");
- table.showFooter(true);
- sheet.options.allowCellOverflow = true;
- //Adjust row height and column width
- sheet.setColumnWidth(0, 50);
- sheet.setColumnWidth(1, 115);
- sheet.setColumnWidth(2, 115);
- sheet.options.gridline = { showHorizontalGridline: false, showVerticalGridline: false };
- sheet.setDataSource(dataSource1);
- var CheckBox = spreadNS.CellTypes.CheckBox;
- sheet.setCellType(1,0,new CheckBox());
- sheet.setCellType(2,0,new CheckBox());
- sheet.setCellType(3,0,new CheckBox());
- spread.resumePaint();
- spread.bind(spreadNS.Events.ButtonClicked, function (e, args) {
- var sheet = args.sheet, row = args.row, col = args.col;
- var cellType = sheet.getCellType(row, col);
- if (cellType instanceof GC.Spread.Sheets.CellTypes.CheckBox) {
- console.log(1);
- }else {
- console.log(2);
- }
- });
- };
复制代码 |
|