How to use the handsontable.helper function in handsontable

To help you get started, we’ve selected a few handsontable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github valor-software / ng2-handsontable / demo / src / components / handsontable / sheet-demo.ts View on Github external
constructor() {
    this.data = Handsontable.helper['createSpreadsheetData'](100, 12); // tslint:disable-line:no-string-literal
    this.options = {
      height: 396,
      colHeaders: true,
      rowHeaders: true,
      stretchH: 'all',
      columnSorting: true,
      contextMenu: true
    };
  }
}
github tabixio / tabix / src / components / Handsontable / settingsMapper.js View on Github external
c.sortFunction=function (sortOrder) {
                    // Handsontable's object iteration helper
                    let objectEach = Handsontable.helper.objectEach;
                    let unitsRatios = {
                        'TiB': 1024*1024*1024*1024,
                        'GiB': 1024*1024*1024,
                        'MiB': 1024*1024,
                        'KiB': 1024,
                        'B': 1,
                    };
                    let parseUnit = function(value, unit, ratio) {
                        if (isNil(value)) return value;
                        if (isNaN(value) && value.indexOf(' ' + unit) > -1) {
                            value = parseFloat(value.replace(unit, '')) * ratio;
                        }
                        return value;
                    };
github kpi-intelligence / handsontable-key-value / src / filters / keyValueComponent.js View on Github external
visualcol: visualIndex,
        prop: columnSettings.data,
        row: null,
        visualRow: null,
      };

      getSourceItems.call(cellProperties, columnSettings.source, (items) => {
        // Prepare the items with key and value properties to be handled by intersectValues transparently
        const visibleValues = items.map(item => ({
          key: item[columnSettings.keyProperty],
          value: item[columnSettings.valueProperty],
        }));
        callback(visibleValues);
      });
    } else {
      const visibleValues = Handsontable.helper.arrayMap(
        this.hot.getDataAtCol(visualIndex),
        v => toEmptyString(v),
      );
      callback(visibleValues);
    }
  }
github handsontable / react-handsontable / test / autoSizeWarning.spec.tsx View on Github external
'the `columns` option is defined as a function', async (done) => {
    console.warn = jasmine.createSpy('warn');

    const wrapper: ReactWrapper<{}, {}, typeof HotTable> = mount(
      <HotTable licenseKey="non-commercial-and-evaluation"
                id="test-hot"
                data={Handsontable.helper.createSpreadsheetData(3, 3)}
                width={300}
                height={300}
                autoRowSize={false}
                autoColumnSize={true}
                columns={function(columnIndex) {
                  return {
                    renderer: function() {}
                  }
                }}
                init={function () {
                  mockElementDimensions(this.rootElement, 300, 300);
                }}>
        <HotColumn/>
        <HotColumn/>
        <HotColumn/>
      </HotTable>, {attachTo: document.body.querySelector('#hotContainer')}
github handsontable / react-handsontable / test / hotColumn.spec.tsx View on Github external
it('should use the renderer component as Handsontable renderer, when it\'s nested under HotColumn and assigned the \'hot-renderer\' attribute', async (done) => {
    const wrapper: ReactWrapper<{}, {}, typeof HotTable> = mount(
      <HotTable licenseKey="non-commercial-and-evaluation"
                id="test-hot"
                data={Handsontable.helper.createSpreadsheetData(100, 2)}
                width={300}
                height={300}
                rowHeights={23}
                colWidths={50}
                autoRowSize={false}
                autoColumnSize={false}
                init={function () {
                  mockElementDimensions(this.rootElement, 300, 300);
                }}>
        <HotColumn/>
        <HotColumn>
          <RendererComponent hot-renderer></RendererComponent>
        </HotColumn>
      </HotTable>, {attachTo: document.body.querySelector('#hotContainer')}
    );
github handsontable / react-handsontable / test / hotTable.spec.tsx View on Github external
it('should use the editor component as Handsontable editor, when it\'s nested under HotTable and assigned the \'hot-editor\' attribute', async (done) => {
    const wrapper: ReactWrapper<{}, {}, typeof HotTable> = mount(
      <HotTable licenseKey="non-commercial-and-evaluation"
                id="test-hot"
                data={Handsontable.helper.createSpreadsheetData(3, 3)}
                width={300}
                height={300}
                rowHeights={23}
                colWidths={50}
                init={function () {
                  mockElementDimensions(this.rootElement, 300, 300);
                }}>
        <EditorComponent hot-editor></EditorComponent>
      </HotTable>, {attachTo: document.body.querySelector('#hotContainer')}
    );

    await sleep(100);

    const hotInstance = wrapper.instance().hotInstance;

    expect((document.querySelector('#editorComponentContainer') as any).style.display).toEqual('none');
github handsontable / react-handsontable / test / componentInternals.spec.tsx View on Github external
render(): React.ReactElement<string> {
        return (
          <div id={this.props.editorId}>
            {this.state.value}
          </div>
        );
      }
    }

    let globalEditorInstance = null;
    let columnEditorInstance = null;
    const wrapper: ReactWrapper<{}, {}, typeof HotTable> = mount(
      <HotTable licenseKey="non-commercial-and-evaluation"
                id="test-hot"
                data={Handsontable.helper.createSpreadsheetData(3, 2)}
                width={300}
                height={300}
                rowHeights={23}
                colWidths={50}
                init={function () {
                  mockElementDimensions(this.rootElement, 300, 300);
                }}>
        <RendererEditor2 editorId={'first-editor'} ref={function (instance) {
          globalEditorInstance = instance;
        }} hot-editor></RendererEditor2>
        <HotColumn/>
        <HotColumn>
          <RendererEditor2 editorId={'second-editor'} ref={function (instance) {
            columnEditorInstance = instance;
          }} hot-editor></RendererEditor2>
        </HotColumn>
github handsontable / react-handsontable / test / reactHooks.spec.tsx View on Github external
const [count, setCount] = useState(0);

      return (
        <div className={'hook-enabled-renderer-container'}>
          <p>{props.value}</p>: <span>{count}</span>
          <button onClick={() => setCount(count + 1)}>
            Click me
          </button>
        </div>
      );
    }

    const wrapper: ReactWrapper<{}, {}, typeof HotTable> = mount(
      <HotTable licenseKey="non-commercial-and-evaluation"
                id="test-hot"
                data={Handsontable.helper.createSpreadsheetData(3, 3)}
                width={300}
                height={300}
                rowHeights={23}
                colWidths={50}
                autoRowSize={false}
                autoColumnSize={false}
                init={function () {
                  mockElementDimensions(this.rootElement, 300, 300);
                }}>
        <HookEnabledRenderer hot-renderer></HookEnabledRenderer>
      </HotTable>, {attachTo: document.body.querySelector('#hotContainer')}
    );

    await sleep(100);

    const hotInstance = wrapper.instance().hotInstance;
github handsontable / react-handsontable / test / reactContext.spec.tsx View on Github external
class EditorComponent3 extends React.Component {
      render() {
        return (
          <>
            {this.context}
          </>
        )
      }
    }
    EditorComponent3.contextType = TestContext;

    const wrapper: ReactWrapper<{}, {}, typeof HotTable> = mount(
      <TestContext.Provider value={'testContextValue'}>
        <HotTable licenseKey="non-commercial-and-evaluation"
                  id="test-hot"
                  data={Handsontable.helper.createSpreadsheetData(3, 2)}
                  width={300}
                  height={300}
                  rowHeights={23}
                  colWidths={50}
                  autoRowSize={false}
                  autoColumnSize={false}
                  init={function () {
                    mockElementDimensions(this.rootElement, 300, 300);
                  }}
                  ref={function (instance) {
                    hotTableInstance = instance;
                  }}>
          <HotColumn>
            <RendererComponent2 hot-renderer/>
            <EditorComponent2 hot-editor/>
          </HotColumn>
github handsontable / angular-handsontable / projects / hot-table / src / lib / hot-table.component.spec.ts View on Github external
await TestBed.compileComponents().then(() => {
      fixture = TestBed.createComponent(TestComponent);
      const app = fixture.componentInstance;

      app.prop['settings'] = {
        data: Handsontable.helper.createSpreadsheetData(5, 5)
      };

      fixture.detectChanges();
      expect(app.getHotInstance(app.id).getDataAtCell(0, 0)).toBe('A1');
    });
  });