Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                  <div id="app"></div>
              
            
!

CSS

              
                
              
            
!

JS

              
                const {
  PagingState,
  SortingState,
  FilteringState,
  GroupingState,
  EditingState,
  SelectionState,
  RowDetailState,
  IntegratedSorting,
  IntegratedFiltering,
  IntegratedPaging,
  IntegratedGrouping,
  IntegratedSelection
} = DevExpress.DXReactGrid;

const {
  Grid,
  Table,
  TableHeaderRow,
  TableFilterRow,
  TableSelection,
  PagingPanel,
  GroupingPanel,
  TableGroupRow,
  TableEditRow,
  TableEditColumn,
  TableRowDetail,
  DragDropProvider,
  TableColumnReordering,
  TableColumnVisibility,
  ColumnChooser,
  Toolbar
} = DevExpress.DXReactGridBootstrap3;


const CustomTableRowDetail = ({ row }) => 
  <div>Details about '{row.name}' by {row.artist}</div>;

class App extends React.PureComponent {
  render() {
    const { rows, columns } = this.state;

    return (
      <Grid rows={rows} columns={columns} getRowId={this.getRowId}>
        <SortingState
          defaultSorting={[{ columnName: "name", direction: "asc" }]}
        />
        <PagingState />
        <FilteringState />
        <SelectionState />
        <GroupingState />
        <EditingState onCommitChanges={this.commitChanges} />
        <RowDetailState />
        <IntegratedSorting />
        <IntegratedFiltering />
        <IntegratedGrouping />
        <IntegratedPaging />
        <IntegratedSelection />
        <DragDropProvider />
        <Table />
        <TableColumnReordering defaultOrder={["name", "artist", "year"]} />
        <TableColumnVisibility />
        <TableHeaderRow showSortingControls showGroupingControls />
        <TableFilterRow />
        <TableSelection highlightRow />
        <TableEditRow />
        <TableEditColumn showAddCommand showEditCommand showDeleteCommand />
        <TableRowDetail contentComponent={ CustomTableRowDetail } />
        <PagingPanel pageSizes={[0, 5, 10, 20]} />
        <TableGroupRow />
        <Toolbar />
        <GroupingPanel showSortingControls showGroupingControls />
        <ColumnChooser />
      </Grid>
    );
  }

  getRowId(row) {
    return row.id;
  }

  commitChanges({ added, changed, deleted }) {
    const rowById = id => _.find(this.state.rows, r => r.id === parseInt(id));
    if (changed) {
      for (let id in changed) {
        const changedRow = rowById(id);
        const otherRows = _.without(this.state.rows, changedRow);

        this.setState({
          rows: [
            ...otherRows,
            {
              ...changedRow,
              ...changed[id]
            }
          ]
        });
      }
    }
    if (deleted) {
      for (let id of deleted) {
        const deletedRow = rowById(id);
        this.setState({
          rows: _.without(this.state.rows, deletedRow)
        });
      }
    }
    if (added) {
      let largestId = this.state.rows.reduce((r,v) => v.id > r ? v.id : r , 0);
      for (let newObject of added)
        this.setState({
          rows: [
            ...this.state.rows,
            {
              ...newObject,
              id: ++largestId
            }
          ]
        });
    }
  }

  constructor(props) {
    super(props);

    this.commitChanges = this.commitChanges.bind(this);

    this.state = {
      columns: [
        { name: "name", title: "Name" },
        { name: "artist", title: "Artist" },
        { name: "year", title: "Year" }
      ],
      rows: [
        {
          id: 1,
          name: "Their Satanic Majesties Request",
          artist: "The Rolling Stones",
          year: 1967
        },
        { id: 2, name: "Prime Cuts", artist: "David Bowie", year: 1983 },
        { id: 3, name: "Human", artist: "Rag'n'Bone Man", year: 2017 },
        { id: 4, name: "Kill 'Em All", artist: "Metallica", year: 1983 },
        {
          id: 5,
          name: "Colour by Numbers",
          artist: "Culture Club",
          year: 1983
        },
        {
          id: 6,
          name: "Born in the U.S.A.",
          artist: "Bruce Springsteen",
          year: 1984
        },
        { id: 7, name: "Disraeli Gears", artist: "Cream", year: 1967 },
        {
          id: 8,
          name: "Between the Buttons",
          artist: "The Rolling Stones",
          year: 1967
        },
        {
          id: 9,
          name: "Sgt. Pepper's Lonely Hearts Club Band",
          artist: "The Beatles",
          year: 1967
        },
        {
          id: 10,
          name: "The Battle of Los Angeles",
          artist: "Rage Against the Machine",
          year: 1999
        },
        { id: 11, name: "The Slim Shady LP", artist: "Eminem", year: 1999 }
      ]
    };
  }
}

ReactDOM.render(<App />, document.getElementById("app"));

              
            
!
999px

Console