1

I have a .net core 3.1 react web application. I'm interested in utilizing adazzle's react-data-grid but I have not been able to locate any example implementations. Are there any examples for react-data-grid in .net core?

I'm familiar with jquery datatables

user2370664
  • 381
  • 5
  • 8
  • 30

1 Answers1

0

If you go to their examples. Just click Sandbox on the example grid and it opens a new codesandbox with all the code you need.

The only thing you need with .net-core 3.1? is to get your data to and from the server. Other than that you're using it on the front end with JS or TS

Here is a basic example

import React from "react";
import ReactDOM from "react-dom";
import ReactDataGrid from "react-data-grid";
import "./styles.css";

const columns = [
  { key: "id", name: "ID", editable: true },
  { key: "title", name: "Title", editable: true },
  { key: "complete", name: "Complete", editable: true }
];

const rows = [
  { id: 0, title: "Task 1", complete: 20 },
  { id: 1, title: "Task 2", complete: 40 },
  { id: 2, title: "Task 3", complete: 60 }
];

class Example extends React.Component {
  state = { rows };

  onGridRowsUpdated = ({ fromRow, toRow, updated }) => {
    this.setState(state => {
      const rows = state.rows.slice();
      for (let i = fromRow; i <= toRow; i++) {
        rows[i] = { ...rows[i], ...updated };
      }
      return { rows };
    });
  };
  render() {
    return (
      <ReactDataGrid
        columns={columns}
        rowGetter={i => this.state.rows[i]}
        rowsCount={3}
        onGridRowsUpdated={this.onGridRowsUpdated}
        enableCellSelect={true}
      />
    );
  }
}

const rootElement = document.getElementById("root");
ReactDOM.render(<Example />, rootElement);
Train
  • 3,420
  • 2
  • 29
  • 59