react-data-grid icon indicating copy to clipboard operation
react-data-grid copied to clipboard

Styles/themes not applied

Open mrn3 opened this issue 10 years ago • 6 comments

I am using webpack, and when I set it up with the example, it is just white (no styling). How do I use styles out of the box?

Do I need to include a css file or something?

import React from 'react'
import ReactDataGrid from 'react-data-grid/addons'

var _rows = [];

for (var i = 1; i < 1000; i++) {
  _rows.push({
    id: i,
    task: 'Task ' + i,
    complete: Math.min(100, Math.round(Math.random() * 110)),
    priority : ['Critical', 'High', 'Medium', 'Low'][Math.floor((Math.random() * 3) + 1)],
    issueType : ['Bug', 'Improvement', 'Epic', 'Story'][Math.floor((Math.random() * 3) + 1)],
    startDate: Date(2015, 3, 1),
    completeDate: Date(2015, 3, 1)
  });
}

//function to retrieve a row for a given index
var rowGetter = function(i){
  return _rows[i];
};

//Columns definition
var columns = [
  {
    key: 'id',
    name: 'ID',
    resizable : true
  },
  {
    key: 'task',
    name: 'Title',
    resizable : true
  },
  {
    key: 'priority',
    name: 'Priority',
    resizable : true
  },
  {
    key: 'issueType',
    name: 'Issue Type',
    resizable : true
  },
  {
    key: 'complete',
    name: '% Complete',
    resizable : true
  },
  {
    key: 'startDate',
    name: 'Start Date',
    resizable : true
  },
  {
    key: 'completeDate',
    name: 'Expected Complete',
    resizable : true
  }
]

class ImportCsvStudentHome extends React.Component {

  displayName: 'ImportCsvStudentHome'

  render() {
    return (
      <div>
        <ReactDataGrid
          columns={columns}
          rowGetter={rowGetter}
          rowsCount={_rows.length}
          minHeight={500} />
      </div>
    )
  }
}

export default ImportCsvStudentHome

mrn3 avatar Apr 15 '16 18:04 mrn3

Yes, there is a themes/react-data-grid.less and a themes/react-data-grid.css file. You should use either one of these. I will add this to the documentation

malonecj avatar Apr 19 '16 09:04 malonecj

any news on this?

nicomfe avatar Jul 05 '16 03:07 nicomfe

This themes folder doesn't include styles for the react-contextmenu extension, either. Either some default styling should be included, or it should document that the user needs to write their own.

SupernaviX avatar Sep 02 '16 17:09 SupernaviX

Importing the less file doesn't work. Error message is:

"ERROR in ./~/css-loader!./~/less-loader!./src/main/webapp/less/main.less Cannot resolve file select.less near lines: @import './node_modules/react-select/less/select.less'!

The import should be ../ node... instead

Darkvater avatar Nov 08 '16 03:11 Darkvater

In the react-data-grid.css file, is there any way to avoid importing less file? I don't want to add less-loader if my projet doesn't need it..

kzde avatar Nov 23 '16 14:11 kzde

All the styles come for free with react-data-grid after version 2.0.0. It just need to override the classnames you want to.

Cheers.

diogofcunha avatar Jan 25 '17 12:01 diogofcunha