| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import * as React from 'react';
- import {TabulatorFull as Tabulator} from "tabulator-tables"; //import Tabulator library
- import './Tabulator.css';
- export default function Zcbfwf({data}) {
- const myRef = React.useRef();
- const myTable = React.useRef(null);
- React.useEffect(() => {
- myTable.current = new Tabulator(myRef.current, {
- index: "key",
- height: 600,
- data: data, //link data to table
- reactiveData: false, //enable data reactivity
- dataTreeStartExpanded:true,
- dataTree: true,
- selectableRows:1, //make rows selectable
- editTriggerEvent:"dblclick", //trigger edit on double click
- dataTreeStartExpanded:function(row, level){
- //console.log(row);
- //console.log(level);
- return true; //expand rows where the "driver" data field is true;
- },
- columns: [ //Define Table Columns 序号", "名称", "取费基数", "计算基础","费率", "金额", "类别
- {title:"序号", field:"序号", width:80, headerSort:false,}, //never hide this column
- {title:"名称", field:"名称", width:150, headerSort:false, formatter:"textarea"}, //hide this column first
- {title:"项目价值", field:"项目价值", width:100, formatter:"money", },
- {title:"服务内容", field:"服务内容", width:100, formatter:"textarea"},
- {title:"计算基础", field:"计算基础", width:100, formatter:"textarea"},
- {title:"费率", field:"费率", width:100, formatter:"money"},
- {title:"金额", field:"金额", width:100, formatter:"money"},
-
- ]
- });
-
- myTable.current.on("cellDblClick", function(e, cell){
- //e - the click event object
- //cell - cell component
- console.log(cell);
- });
-
- //myTable.current.on("rowSelected", handleSelect);
-
-
-
-
-
-
-
- }, [data]);
- return (
- <div ref={myRef}>
- </div>
- );
- }
|