我在功能例子上做了数据,不会报错,但仍然无法输入,
代码
- import * as React from 'react';
- import * as ReactDOM from 'react-dom';
- import '@grapecity/spread-sheets-resources-zh';
- GC.Spread.Common.CultureManager.culture("zh-cn");
- import GC from '@grapecity/spread-sheets';
- import { SpreadSheets } from '@grapecity/spread-sheets-react';
- import './styles.css';
- const Component = React.Component;
- const GCsheets = GC.Spread.Sheets;
- function _getElementById(id) {
- return document.getElementById(id);
- }
- class App extends Component {
- constructor(props) {
- super(props);
- this.spread = null;
- this.table = null;
- this.state = {
- dirtyRowsValue: null
- };
- }
- render() {
- return (
- <div class="sample-tutorial">
- <div class="sample-spreadsheets">
- <SpreadSheets workbookInitialized={spread=>this.initSpread(spread)}>
- </SpreadSheets>
- </div>
- <Panel
- dirtyRowsValue={this.state.dirtyRowsValue}
- onGetDirtyRowsClickEvent={(e)=>{this.onGetDirtyRowsClickEvent(e)}}
- />
- </div>
- );
- }
- initSpread(spread) {
- this.spread = spread;
- spread.suspendPaint();
- let sheet = spread.getActiveSheet();
- let data = {
- name: 'Jones', region: 'East',
- sales: [
- {orderDate: '1/6/2013', item: 'Pencil', units: 95, cost: 1.99, isDelivered: true},
- {orderDate: '4/1/2013', item: 'Binder', units: 60, cost: 4.99, isDelivered: false},
- {orderDate: '6/8/2013', item: 'Pen Set', units: 16, cost: 15.99, isDelivered: false}
- ]
- };
- let convert = function (item) {
- return item['cost'] + '
- ;
- }
- let table = sheet.tables.add('tableSales', 0, 0, 5, 5);
- this.table = table;
- let range = sheet.getRange(1, 0,3,1);
- table.style(GCsheets.Tables.TableThemes["medium4"]);
- let tableColumn1 = new GCsheets.Tables.TableColumn(1, "orderDate", "Order Date", "yyyy-mm-dd");
- let tableColumn2 = new GCsheets.Tables.TableColumn(2, "item", "Item");
- let tableColumn3 = new GCsheets.Tables.TableColumn(3, "units", "Units");
- let tableColumn4 = new GCsheets.Tables.TableColumn(4, "cost", "Cost", null, null, convert);
- let tableColumn5 = new GCsheets.Tables.TableColumn(5, "isDelivered", "Delivered");
- table.autoGenerateColumns(false);
- table.bind([tableColumn1, tableColumn2, tableColumn3, tableColumn4, tableColumn5], 'sales', data);
- range.cellButtons([
- {
- imageType: GCsheets.ButtonImageType.ellipsis,
- position: GCsheets.ButtonPosition.right,
- }
- ])
- spread.resumePaint();
- }
- onGetDirtyRowsClickEvent(e) {
- let table = this.table;
- if (table) {
- let dataArr = table.getDirtyRows();
- let str = "";
- for (let i = 0; i < dataArr.length; i ++) {
- str += dataArr[i].row + ", ";
- }
- this.setState({ dirtyRowsValue: str });
- }
- }
- }
- class Panel extends Component{
- constructor(props){
- super(props);
- }
- render(){
- return (
- <div class="options-container">
- <div class="option-row">
- <label class="custom-label">Change table data and click button to get the dirty rows.</label>
- </div>
- <input type="button" id="getState" value="Get Dirty Rows" onClick={(e)=>{this.props.onGetDirtyRowsClickEvent(e)}} />
- <textarea id="stateText" class="state-text" value={this.props.dirtyRowsValue}></textarea>
- </div>
- );
- }
- }
- ReactDOM.render(<App />, _getElementById('app'));
复制代码
|