wijmo.react Module

File
wijmo.react.js
Module
wijmo.react

Wijmo interop module for React.

This module provides React components that encapsulate Wijmo controls.

To use it, your application must include references to the React and ReactDOM libraries, as well as the regular Wijmo CSS and js files.

To add Wijmo controls to React components, include the appropriate tags in your JSX (or TSX) files. For example, the code below adds an InputNumber control to a React component:

<label htmlFor="inputnumber">Here's an InputNumber control:</label>
<Wj.InputNumber
  id="inputNumber"
  format="c2"
  min={ 0 } max={ 10 } step={ .5 }
  value={ this.state.value }
  valueChanged={ this.valueChanged }/>

The example illustrates the following important points:

  1. Wijmo controls have tag names that start with the "Wj" prefix, followed by the control name. The "Wj" is a shorthand for the full module name "wijmo.react" which can also be used.
  2. The tag attribute names match the control's properties and events.
  3. Attribute values enclosed in quotes are interpreted as strings, and values enclosed in curly braces are interpreted as JavaScript expressions.
  4. React components do not have implicit two-way bindings, so controls that modify values typically use event handlers to explicitly apply changes to the parent component's state.

To illustrate this last point, the component that contains the markup given above would typically implement a "valueChanged" event handler as follows:

valueChanged: function(s, e) {
  this.setState({ value, s.value });
}

The event handler calls React's setState method to update the component state, automatically triggering a UI update. Notice that the method does not write directly into the "state" object, which should be treated as immutable in React applications.

All Wijmo React components include an "initialized" event that is raised after the control has been added to the page and initialized. You can use this event to perform additional initialization in addition to setting properties in markup. For example:

<Wj.FlexGrid
  initialized={ function(s,e) {

    // assign a custom MergeManager to the grid
    s.mergeManager = new CustomMergeManager(s);

  }}
/>

Properties

Properties

AutoComplete

React component that encapsulates the TreeView control.

Type

AutoComplete

React component that encapsulates the AutoComplete control.

Type

BulletGraph

React component that encapsulates the BulletGraph control.

Type

Calendar

React component that encapsulates the Calendar control.

Type

ColorPicker

React component that encapsulates the ColorPicker control.

Type

ComboBox

React component that encapsulates the ComboBox control.

Type

FlexChart

React component that encapsulates the FlexChart control.

The example below shows how to instantiate and initialize a FlexChart control in JSX:

<Wj.FlexChart
  itemsSource={ this.state.data }
  bindingX="name"
  header={ this.state.header }
  footer={ this.state.footer }
  axisX={​{ title: this.state.titleX }}
  axisY={​{ title: this.state.titleY }}
  legend={​{ position: this.state.legendPosition }}
  series={[
      { name: 'Sales', binding: 'sales' },
      { name: 'Expenses', binding: 'expenses' },
      { name: 'Downloads', binding: 'downloads', chartType: 'LineSymbols' }
  ]} />

The code sets the itemsSource property to a collection that contains the data to chart and the bindingX property to specify the name of the data property to use for the chart's X values.

It sets the header and footer properties to specify the chart titles, and customizes the chart's axes and legend.

Finally, it sets the series property to an array that specifies the data items that the chart should display.

Type

FlexGrid

React component that encapsulates the FlexGrid control.

The example below shows how to instantiate and initialize a FlexGrid control in JSX:

<Wj.FlexGrid
  autoGenerateColumns={ false }
  columns={[
    { binding: 'name', header: 'Name' },
    { binding: 'sales', header: 'Sales', format: 'c0' },
    { binding: 'expenses', header: 'Expenses', format: 'c0' },
    { binding: 'active', header: 'Active' },
    { binding: 'date', header: 'Date' }
  ]}
  itemsSource={ this.state.data } />

The code sets the autoGenerateColumns property to false, then sets the columns property, and finally sets the itemsSource property. This order is important, it prevents the grid from automatically generating the columns.

Type

GroupPanel

React component that encapsulates the GroupPanel control.

Type

InputColor

React component that encapsulates the InputColor control.

Type

InputDate

React component that encapsulates the InputDate control.

Type

InputDateTime

React component that encapsulates the InputDateTime control.

Type

InputMask

React component that encapsulates the InputMask control.

Type

InputNumber

React component that encapsulates the InputNumber control.

Type

InputTime

React component that encapsulates the InputTime control.

Type

LinearGauge

React component that encapsulates the LinearGauge control.

The example below shows how to instantiate and initialize a LinearGauge control in JSX:

<Wj.LinearGauge
  min={ 0 } max={ 1000 } step={ 50 } isReadOnly={ false }
  value={ this.state.view.currentItem.sales }
  valueChanged={ this.salesChanged }
  format="c0" thumbSize={ 20 } showRanges={ false }
  face={​{ thickness:0.5 }}
  pointer={​{ thickness:0.5 }}
  ranges={[
      { min: 0, max: 333, color: 'red' },
      { min: 333, max: 666, color: 'gold' },
      { min: 666, max: 1000, color: 'green' }
  ]} />

The code min, max, step, and isReadOnly properties to define the range of the gauge and to allow users to edit its value. Next, it sets the value and valueChanged properties to create a two-way binding for the gauge's value.

Then it sets the format, thumbSize, and showRanges properties to define the appearance of the gauge. Finally, the markup sets the thickness of the face and pointer ranges, and extra ranges that will control the color of the value range depending on the gauge's current value.

Type

ListBox

React component that encapsulates the ListBox control.

Type

MultiAutoComplete

React component that encapsulates the MultiAutoComplete control.

Type

MultiSelect

React component that encapsulates the MultiSelect control.

Type

PivotChart

React component that encapsulates the PivotChart control.

Type

PivotGrid

React component that encapsulates the PivotGrid control.

Type

PivotPanel

React component that encapsulates the PivotPanel control.

Type

RadialGauge

React component that encapsulates the RadialGauge control.

The example below shows how to instantiate and initialize a RadialGauge control in JSX:

<Wj.RadialGauge
  min={ 0 } max={ 1000 } step={ 50 } isReadOnly={ false }
  value={ this.state.view.currentItem.sales }
  valueChanged={ this.salesChanged }
  format="c0" thumbSize={ 12 } showRanges={ false } showText="Value"
  face={​{ thickness:0.5 }}
  pointer={​{ thickness:0.5 }}
  ranges={[
      { min: 0, max: 333, color: 'red' },
      { min: 333, max: 666, color: 'gold' },
      { min: 666, max: 1000, color: 'green' }
  ]} />

The code min, max, step, and isReadOnly properties to define the range of the gauge and to allow users to edit its value. Next, it sets the value and valueChanged properties to create a two-way binding for the gauge's value.

Then it sets the format, thumbSize, showText, and showRanges properties to define the appearance of the gauge. Finally, the markup sets the thickness of the face and pointer ranges, and extra ranges that will control the color of the value range depending on the gauge's current value.

Type