javascript - ag-grid with react not working -
i have problem getting ag-grid work react app. whatever try, text, don't see grid. don't know i'm missing. here code:
/* * ---------------------------- * index.js * ---------------------------- */ import react 'react'; import reactdom 'react-dom'; import './index.css'; import app './app'; import registerserviceworker './registerserviceworker'; import { browserrouter } 'react-router-dom' reactdom.render( <browserrouter> <app /> </browserrouter> , document.getelementbyid('root')); registerserviceworker(); /* * ---------------------------- * app.js * ---------------------------- */ import react, { component } 'react'; import header './header'; import main './main'; import './styles/app.css'; class app extends component { render() { return ( <div classname="app"> <header /> <main /> </div> ); } } export default app; /* * ---------------------------- * header.js * ---------------------------- */ import react, { component } 'react'; import { link } 'react-router-dom' import './styles/header.css'; class header extends component { render() { return ( <div classname="app-header"> <h2>my application</h2> <link to='/'>home</link> <link to='/cities'>cities</link> <link to='/countries'>countries</link> </div> ); } } export default header; /* * ---------------------------- * main.js * ---------------------------- */ import react, { component } 'react'; import { switch, route } 'react-router-dom'; import home './pages/home'; import stations './pages/cities'; import countries './pages/countries'; class main extends component { render() { return ( <div classname="app-main"> <switch> <route exact path='/' component={home}/> <route path='/cities' component={cities}/> <route path='/countries' component={countries}/> </switch> </div> ); } } export default main; /* * ---------------------------- * countries.js * ---------------------------- */ import react, { component } 'react'; import { aggridreact } 'ag-grid-react'; class countries extends component { constructor(props) { super(props); this.state = { columndefs: this.createcolumndefs(), rowdata: this.createrowdata() }; } createcolumndefs() { return [ {headername: "#", width: "30px", checkboxselection: true, suppresssorting: true, suppressmenu: true, pinned: true }, {headername: "name", field: "name"}, {headername: "abbreviation", field: "abbr"}, {headername: "id", field: "id"} ]; } createrowdata() { return [ {name: "sweden", id: 1, abbr: "se"}, {make: "denmark", id: 2, abbr: "dk"}, {make: "norway", id: 3, abbr: "no"} ]; } render() { let containerstyle = { height: '800px', width: '500px', margin: 'auto' }; //console.log(this.state.columndefs); return ( <div> <div style={containerstyle} classname="ag-fresh"> <aggridreact // properties columndefs={this.state.columndefs} rowdata={this.state.rowdata} groupheaders="false" rowselection="multiple" enablecolresize="true" enablesorting="true" enablefilter="true" rowheight="22" debug="true" /> </div> </div> ) } }; export default countries;
i didn't include css files , home.js
, cities.js
since render nothing @ moment. result get:
as can see, don't see grid, strange text. have been browsing long time looking @ ag-grid homepage , trying example code, time.
any ideas?
this line problem:
{headername: "#", width: "30px", checkboxselection: true, suppresssorting: true, suppressmenu: true, pinned: true },
change this:
{headername: "#", width: 30, checkboxselection: true, suppresssorting: true, suppressmenu: true, pinned: true },
found in errors in console, though warning, still messes grid being unrenderable
Comments
Post a Comment