react-data-grid AutoCompleteEditor not working - reactjs

import React, {Component} from 'react'
import ReactDataGrid from 'react-data-grid'
import update from 'immutability-helper'
import { Editors, Formatters } from 'react-data-grid-addons'
const {AutoComplete, AutoCompleteEditor, DropDownEditor} = Editors
const { DropDownFormatter } = Formatters
const productNames = [
{
id: 0,
title: 'productName1',
},
{
id: 1,
title:'productName2'
},
]
const productNamesEditor = <AutoCompleteEditor options={productNames} />
const columns= [
{
key: 'id',
name: 'ID',
},
{
key: 'product_name',
name: 'Product Name',
editable: true,
editor: productNamesEditor,
},
{
key: 'product_qty',
name: 'Product Qty',
editable:true,
},
{
key: 'product_rate',
name: 'Product Rate',
editable:true,
},
{
key: 'product_disc',
name: 'Product Disc',
editable:true,
},
]
class LineItems extends Component {
constructor(props) {
super(props)
this._columns = columns
console.log(this._columns)
this.state = {rows: this.props.lineItems.rows}
}
rowGetter = (i) => {
return this.state.rows[i];
};
handleGridRowsUpdated = ({ fromRow, toRow, updated }) => {
console.log(fromRow)
console.log(updated)
// calling slice() without arguments makes a copy of array
let rows = this.state.rows.slice();
for (let i = fromRow; i <= toRow; i++) {
let rowToUpdate = rows[i];
let updatedRow = update(rowToUpdate, {$merge: updated});
rows[i] = updatedRow;
this.setState({ rows })
this.props.onGridRowsUpdated(rows)
}
}
render () {
return (
<ReactDataGrid
ref={node => this.grid=node}
enableCellSelect={true}
columns={this._columns}
rowGetter={this.rowGetter}
rowsCount={this.state.rows.length}
maxHeight={300}
onGridRowsUpdated={this.handleGridRowsUpdated}
/>
)
}
}
export default LineItems
Error: Element type is invalid: expected a string (for built-in
components) or a class/function (for composite components) but got:
undefined. You likely forgot to export your component from the file
it's defined in, or you might have mixed up default and named imports.
Check the render method of EditorContainer....
The grid renders. If I try to enter/edit the cell to which I have set the AutoCompleteEditor, I get the above-mentioned error.

Minor error in my code:
const {AutoComplete, AutoCompleteEditor, DropDownEditor} = Editors
should have been
const {AutoComplete: AutoCompleteEditor, DropDownEditor} = Editors

Related

Row level operations on react-table: React Js

I am trying to implement a feature where in on click of each row, I need to get the info of the row that is been clicked and corresponding row color should be changed to something else. And when I select multiple rows using Ctrl+mouse-click the corresponding rows color should also get changed, and need to get the info of corresponding rows in the form of array. I need to have a common getTrProps function that should implement both of this . Can someone help me out with this
Codesandbox: https://codesandbox.io/s/react-table-row-table-0bbyi
App
import * as React from "react";
import { render } from "react-dom";
import DataGrid from "./DataGrid";
import { Column } from "react-table";
interface IProps {}
interface IState {
data: IUser[];
columns: Column<IUser>[];
}
export interface IUser {
firstName: string;
status: "Submitted" | "Pending" | "Approved";
age: string;
}
export interface IColum {
Header: string;
accessor: string;
}
class App extends React.Component<IProps, IState> {
constructor(props: IProps) {
super(props);
this.state = {
data: [],
columns: []
};
}
componentDidMount() {
this.getData();
this.getColumns();
}
getData = () => {
const data: IUser[] = [
{ firstName: "Jack", status: "Submitted", age: "14" },
{ firstName: "Simon", status: "Pending", age: "15" },
{ firstName: "Pete", status: "Approved", age: "17" }
];
this.setState({ data });
};
getColumns = () => {
const columns: IColum[] = [
{
Header: "First Name",
accessor: "firstName"
},
{
Header: "Status",
accessor: "status"
},
{
Header: "Age",
accessor: "age"
}
];
this.setState({ columns });
};
onClickRow = (rowInfo: IUser) => {
console.log("You clicked: " + JSON.stringify(rowInfo));
};
render() {
return (
<>
<DataGrid
data={this.state.data}
columns={this.state.columns}
rowClicked={this.onClickRow}
/>
<DataGrid data={this.state.data} columns={this.state.columns} />
</>
);
}
}
DataGrid
import * as React from "react";
import ReactTable, {
RowInfo,
Column,
ComponentPropsGetterR
} from "react-table";
import "react-table/react-table.css";
import { IUser, IColum } from ".";
interface IProps {
data: IUser[];
columns: Column<IUser>[];
// The ? makes it optional
rowClicked?: (user: IUser) => void;
}
export default class DataGrid extends React.Component<IProps> {
rowClick: ComponentPropsGetterR = (state: any, rowInfo: RowInfo) => {
const rowClicked = this.props.rowClicked;
return rowClicked
? {
onClick: () => rowClicked(rowInfo.original as IUser)
}
: {};
};
render() {
return (
<ReactTable
data={this.props.data}
columns={this.props.columns}
getTrProps={this.rowClick}
/>
);
}
}
Here is Your Final Answer :
https://codesandbox.io/s/react-table-row-table-3xwxi
you can now hold Ctrl Key and Select as many row as you want and you can toggle between.
and if you don't hold the key you can select one
you can see each time you choose a row color of the row Changes.
and you have all the data in this.state.allData.
and all of this in typescript as you want from your sandbox.

Enzyme setState not re-rendering the component

I am trying to set a state using enzyme method. After setting a state inside test case I was able to get it back again within the test case which proves that setState is working and I can see the expected output in console. However, inside component I was not able to get state which was set by enzyme because of this my is failing and I am not getting desire view back from component, here is screenshot. You can see there is not data grid table rendered despite having rows data.
table.js
import React, { Component } from 'react';
import styled from 'styled-component';
import ReactDataGrid from 'react-data-grid';
import { Filters } from 'react-data-grid-addons';
import PropTypes from 'prop-types';
export class Table extends Component {
constructor(props) {
super(props);
const {
NumericFilter,
AutoCompleteFilter,
} = Filters;
this.columns = [
{ key: "id", name: "ID", editable: true },
{ key: "title", name: "Title", editable: true },
{ key: "complete", name: "Complete", editable: true }
];
this.state = {
rows: [],
};
}
renderRow = (i) => {
const { rows } = this.state;
return rows[i];
}
render() {
const { className } = this.props;
const { rows } = this.state;
console.log('rows Length', rows.length) // always 0
return (
<div className={className}>
{rows.length
? (
<ReactDataGrid
rowHeight={50}
columns={this.columns}
rowGetter={this.renderRow}
rowsCount={rows.length}
/>
)
: <span id="no-product-message">No Items to be Shown</span>
}
</div>
);
}
}
Table.propTypes = {
className: PropTypes.string,
};
Table.defaultProps = {
className: '',
};
export default styled(Table)`
.react-grid-HeaderCell{
white-space: normal !important;
}
.react-grid-Cell__value{
display: flex;
align-items: center;
}
`;
mountWithTheme
export const mountWithTheme = (children, options) => (
mount(<ThemeProvider theme={theme}>{children}</ThemeProvider>, options)
);
test case
it('should render table if product data is available', () => {
const wrapper = mountWithTheme(<Table />).find(Table);
const instance = wrapper.instance();
jest.spyOn(instance, 'renderRow');
instance.setState({
rows: [{ id: 0, title: "Task 1", complete: 20 }],
});
console.log(instance.state.rows) // [{ id: 0, title: "Task 1", complete: 20 }]
expect(wrapper.find('ReactDataGrid').exists()).toBe(true);
expect(instance.renderRow).toHaveBeenCalledTimes(1);
});

Getting error while showing hiding React Table columns - React JS

I am working on React Table. I am basically a beginner in React. I have a dashboard page where I display a React Table of 8 columns. I have a customize button which will open a popup page, this popup page has 8 check boxes allows me to show/hide those React columns. Initially all the check boxes in this popup page is set to true. When I uncheck a column that particular column get disabled.
There are images in the end to see what I am trying to do.
I will be using this logic for show hide columns (this question was asked by me two days back) -
How to show and hide some columns on React Table?
The React Table data is like this
const columns = [
{
Header: 'Column 1',
accessor: 'firstName',
},
{
Header: 'Column 2',
accessor: 'firstName',
},
{
Header: 'Column 3',
accessor: 'firstName',
},
{
Header: 'Column 4',
accessor: 'firstName',
},
{
Header: 'Column 5',
accessor: 'firstName',
},
{
Header: 'Column 6',
accessor: 'firstName',
},
{
Header: 'Column 7',
accessor: 'firstName'
},
{
Header: 'Column 8',
accessor: 'firstName',
}
];
The start of the dashboard page
class Dashboard extends Component {
constructor(props) {
super(props);
this.state = {
filterState: {},
searchText: '',
isFilterOpen: false,
isCustomizedOpen: false,
isFiltered: false,
isSearched: false,
searchedTableData: [],
filteredTableData: [],
};
this.handleCustClickinv = this.handleCustClickinv.bind(this);
}
This is my code in the render function of my dashboard page for showing the customize button (this is written in parent dashboard page)
{this.state.isCustomizedOpen && <CustomizedView
filterState={this.state.filterState}
applyFilter={(values, clear) => { this.applyFilters(values, clear); }}
/>}
This is the code for the customize button (this is written in parent dashboard page)
<div className="custom-div-dashboard" onClick={() => { this.handleCustClickinv(); }}>
<div className='customize-view-dashboard'>Customized View </div>
</div>
This is function to handle the click on customize button (this is written in parent dashboard page)
handleFilterClickinv() {
if(this.state.isCustomizedOpen) {
this.setState({ isCustomizedOpen: false });
}
const currentState = this.state.isFilterOpen;
this.setState({ isFilterOpen: !currentState });
}
This is my entire popup page which will have 8 check boxes
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { ActionCreators } from '../../../actions';
import './enqCustomizedView.scss';
import ButtonComponent from '../../shared/button/ButtonComponent';
import { CheckBox } from '../../shared/chkbox/CheckBox';
class CustomizedView extends Component {
constructor(props) {
super(props);
this.state = {
items: [
{ id: 1, value: 'Column 1', isChecked: true },
{ id: 2, value: 'Column 2', isChecked: true },
{ id: 3, value: 'Column 3', isChecked: true },
{ id: 4, value: 'Column 4', isChecked: true },
{ id: 5, value: 'Column 5', isChecked: true },
{ id: 6, value: 'Column 6', isChecked: true },
{ id: 7, value: 'Column 7', isChecked: true },
{ id: 8, value: 'Column 8', isChecked: true },
]
};
this.handleCheckChildElement = this.handleCheckChildElement.bind(this);
}
handleClick() {
this.setState({ isChecked: !this.state.isChecked });
}
handleCheckChildElement(event) {
//let items = this.state.items;
let { items } = this.state;
items.forEach(items = () => {
if(items.value === event.target.value) {
items.isChecked = event.target.checked;
}
});
this.setState({ items });
const column1checked = items[0].isChecked;
console.log('column1checked ' + column1checked);
const column2checked = items[1].isChecked;
console.log('column2checked ' + column2checked);
const column3checked = items[2].isChecked;
console.log('column3checked ' + column3checked);
const column4checked = items[3].isChecked;
console.log('column4checked ' + column4checked);
const column5checked = items[4].isChecked;
console.log('column5checked ' + column5checked);
const column6checked = items[5].isChecked;
console.log('column6checked ' + column6checked);
const column7checked = items[6].isChecked;
console.log('column7checked ' + column7checked);
const column8checked = items[7].isChecked;
console.log('column8checked ' + column8checked);
}
render() {
return (
<div className='popup-page-custom' >
<div className='bottomBar'>
<ButtonComponent
text='Apply'
className='activeButton filterMargin'
width='100'
display='inline-block'
onClick={() => { this.props.applyFilter(this.state, false); }}
/>
<ButtonComponent
text='Clear Filter'
className='greyedButton clear-filter'
width='100'
display='block'
marginTop='60'
onClick={() => { this.props.applyFilter(this.state, true); }}
/>
</div>
<div>
<div className='data-points-text'>
<span> Columns </span>
</div>
<div className="App">
<ul>
{
this.state.items.map((item, i) => {
return (<div key={i} ><CheckBox handleCheckChildElement={this.handleCheckChildElement} {...item} /></div>);
})
}
</ul>
</div>
</div>
</div>
);
}
}
CustomizedView.propTypes = {
applyFilter: PropTypes.func.isRequired
};
CustomizedView.defaultProps = {
};
function mapStateToProps(state) {
return {
auth: state.auth
};
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(ActionCreators, dispatch);
}
export default connect(mapStateToProps, mapDispatchToProps)(CustomizedView);
And ultimately this is my checkbox page
import React from 'react';
import PropTypes from 'prop-types';
export const CheckBox = (props) => {
// super(props);
return (
<li>
<input key={props.id} onClick={props.handleCheckChildElement} type="checkbox" checked={props.isChecked} value={props.value} /> {props.value}
</li>
);
};
CheckBox.propTypes = {
id: PropTypes.string,
handleCheckChildElement: PropTypes.func,
isChecked: PropTypes.bool,
value: PropTypes.string,
};
CheckBox.defaultProps = {
id: '',
handleCheckChildElement: null,
isChecked: null,
value: '',
};
export default CheckBox;
This is a very basic (ugly) style of my dashboard page and popup page
This is the error I am getting on Chrome when unchecking the checkboxes
Edit 1 - As per Alireza Yadegari's suggestion, I made a 1 line change. But I am still getting 2 errors.
Edit 2 - As per Alireza Yadegari's suggestion, I applied console.
you have to use this piece of code in your constructor
this.handleCheckChildElement = this.handleCheckChildElement.bind(this)
let { items } = { ...this.state };
this is wrong ....
firstly you destructuring array to object then saying give me items prop from given object... of course this is wrong
const { items} = this.state;
takes items prop from the state
and finally.... implement your task with foreach is bad idea...
CheckBox.defaultProps = {
id: '',
handleCheckChildElement: null,
isChecked: null, value: '',
};
i don't understand what it does. you know?
I think your project is a sample and no need for further examples.
I just say about your mistakes.
first, when you are using methods it is good to use 'bind(this)' to show react where is the method belongs.
secondly, when you are using state, react just allows you to change it in the constructor and wherever you want to change it you have to use 'setState' method (you can read the reason for this in react documentation).
finally, if you have an array in your state you have to get an array in some temp object change the temp object and then apply changes with 'setState' method. if you have more question please feel free to ask.

Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key

I am rendering a table with ant design and it works fine, but there is a warning in the console:
Each record in table should have a unique key prop,or set rowKey
to an unique primary key
My code is as follows:
import React, { Component } from 'react';
import { Table} from 'antd';
import { adalApiFetch } from '../../adalConfig';
class ListTenants extends Component {
constructor(props) {
super(props);
this.state = {
data: []
};
}
fetchData = () => {
adalApiFetch(fetch, "/Tenant", {})
.then(response => response.json())
.then(responseJson => {
if (!this.isCancelled) {
const results= responseJson.map(row => ({
ClientId: row.ClientId,
ClientSecret: row.ClientSecret,
Id: row.Id,
SiteCollectionTestUrl: row.SiteCollectionTestUrl,
TenantDomainUrl: row.TenantDomainUrl
}))
this.setState({ data: results });
}
})
.catch(error => {
console.error(error);
});
};
componentDidMount(){
this.fetchData();
}
render() {
const columns = [
{
title: 'Client Id',
dataIndex: 'ClientId',
key: 'ClientId'
},
{
title: 'Site Collection TestUrl',
dataIndex: 'SiteCollectionTestUrl',
key: 'SiteCollectionTestUrl',
},
{
title: 'Tenant DomainUrl',
dataIndex: 'TenantDomainUrl',
key: 'TenantDomainUrl',
}
];
return (
<Table columns={columns} dataSource={this.state.data} />
);
}
}
export default ListTenants;
Just add a unique key value in tag link this:
<Table
columns={columns}
dataSource={this.state.data}
rowKey="Id" /> // unique key
Hope this help
React renders lists using the key prop. It works so because react allows you to reduce the complexity of diffing algorithms and reduce the number of DOM mutations. You can read a bit more in react reconciliation docs: https://reactjs.org/docs/reconciliation.html
In your case, you added the keys to the columns, but not for rows. Add the key field to the data source. So your code could be the following:
import React, { Component } from 'react';
import { Table} from 'antd';
import { adalApiFetch } from '../../adalConfig';
class ListTenants extends Component {
constructor(props) {
super(props);
this.state = {
data: []
};
}
fetchData = () => {
adalApiFetch(fetch, "/Tenant", {})
.then(response => response.json())
.then(responseJson => {
if (!this.isCancelled) {
const results= responseJson.map(row => ({
key: row.id, // I added this line
ClientId: row.ClientId,
ClientSecret: row.ClientSecret,
Id: row.Id,
SiteCollectionTestUrl: row.SiteCollectionTestUrl,
TenantDomainUrl: row.TenantDomainUrl
}))
this.setState({ data: results });
}
})
.catch(error => {
console.error(error);
});
};
componentDidMount(){
this.fetchData();
}
render() {
const columns = [
{
title: 'Client Id',
dataIndex: 'ClientId',
key: 'ClientId'
},
{
title: 'Site Collection TestUrl',
dataIndex: 'SiteCollectionTestUrl',
key: 'SiteCollectionTestUrl',
},
{
title: 'Tenant DomainUrl',
dataIndex: 'TenantDomainUrl',
key: 'TenantDomainUrl',
}
];
return (
<Table columns={columns} dataSource={this.state.data} />
);
}
}
export default ListTenants;
React Table unique key / rowKey
Each record in table should have a unique key prop,or set rowKey to an unique primary key.
solution 1
each col has a unique key
// each column with unique key
import React from 'react';
import {
Table,
} from 'antd';
const leftTableColumns = [
{
title: 'Page / Modal',
dataIndex: 'pageModal',
key: 'pageModal',
},
{
title: 'Success Rate',
dataIndex: 'successRate',
key: 'successRate',
},
];
const LeftTable = (props) => {
const {
leftTableDatas,
} = props;
return (
<>
<Table
columns={leftTableColumns}
dataSource={leftTableDatas}
/>
</>
);
};
export {
LeftTable,
};
export default LeftTable;
solution 2
only need set rowkey on the table with the unique value
// table with rowkey
import React from 'react';
import {
Table,
} from 'antd';
const leftTableColumns = [
{
title: 'Page / Modal',
dataIndex: 'pageModal',
},
{
title: 'Success Rate',
dataIndex: 'successRate',
},
];
const LeftTable = (props) => {
const {
leftTableDatas,
} = props;
return (
<>
<Table
// shorthand rowKey
rowKey="id"
// rowKey={obj => obj.id}
columns={leftTableColumns}
dataSource={leftTableDatas}
/>
</>
);
};
export {
LeftTable,
};
export default LeftTable;
ref
https://ant.design/components/table/
only you need set rowkey on the table with the unique value.
<Table
dataSource={[finance]}
columns={columns}
rowKey={record => record.id}
/>
Because you are not adding key to dataSource array, add a key in that also.
Like this:
const results= responseJson.map(row => ({
key: row.ClientId, // here
ClientId: row.ClientId,
ClientSecret: row.ClientSecret,
Id: row.Id,
SiteCollectionTestUrl: row.SiteCollectionTestUrl,
TenantDomainUrl: row.TenantDomainUrl
}))
Or you can use any unique value of dataSource array as key by using property rowKey, like this:
<Table
columns={columns}
dataSource={this.state.data}
rowKey="Id" /> // any unique value
Doc Reference.
for me worked this solution
rowKey="{record => record.id}"
or rowKey="id"
but in your collection have to exist the id column
I had your problem and this method answered
<Table
columns={columns}
dataSource={data}
rowKey="name"
/>
I have the same issue but solved with this, Hope this help :)
just add rowKey='id'
I use rowKey = 'id' because 'id' is unique data in variable dataSource, but you can use another unique value from variable dataSource. (with unique value)
import React from 'react'
import { Table } from 'antd'
const committeInformation = () => {
const columns = [
{
key: '0',
title: 'id',
dataIndex: 'id',
},
{
key: '1',
title: 'name',
dataIndex: 'name',
},
{
key: '2',
title: 'email',
dataIndex: 'email'
}
]
const dataSource = [
{
id: '1',
name: 'user 1',
email: 'coco#gmail.com',
},
{
id: '2',
name: 'user 2',
email: 'coco#gmail.com'
}
]
return (
<Table
rowKey='id' //this from variable dataSource
columns={columns}
dataSource={dataSource}
/>
)
}
export default committeInformation
Fast hack
I do assign random math numbers changed to string on each key.?
This is to say my columns become
const columns = [
{
title: 'Client Id',
dataIndex: 'ClientId',
key: () => Math.random().toString(),
},
{
title: 'Site Collection TestUrl',
dataIndex: 'SiteCollectionTestUrl',
key: () => Math.random().toString(),
},
{
title: 'Tenant DomainUrl',
dataIndex: 'TenantDomainUrl',
key: () => Math.random().toString(),
}
];
Hope this helps anybody visiting from the future..........
If your data has no logical key and you only need the key for presentation purposes, you could intercept the data and write a key in using a random number.
export const Table = ({
data,
}: {
data: ITableData[] | undefined;
}) => {
....
if (data) {
data.map((record) => {
return (record.id = Math.floor(Math.random() * 1000000));
});
and then assign the rowkey to the table
<Table dataSource={data} rowKey="id">
in Vue 3:
<a-table
...
:columns="yourColumns"
:data-source="yourData"
// the solution:
:row-key="record => record.id"
// or
:rowKey="record => record.id"
>

Check the render method of `PluginHost$$1

Error appearing is:
bundle.js:1517 Warning: React.createElement: type is invalid -- expected a string (for built-in components)
or a class/function (for composite components) but got: undefined.
You likely forgot to export your component from the file it's defined in.
Check the render method of `PluginHost$$1`.
in PluginHost$$1 (created by Grid)
in Grid (created by Grid$$1)
in Grid$$1 (created by ProductsAndComponentsForLibrary)
in div (created by ProductsAndComponentsForLibrary)
in div (created by ProductsAndComponentsForLibrary)
in div (created by ProductsAndComponentsForLibrary).
This is the relevant code:
import React from 'react';
import {
PagingState,
LocalPaging,
} from '#devexpress/dx-react-grid';
import {
Grid,
Table,
TableHeaderRow,
TableColumnResizing,
PagingPanel,
} from '#devexpress/dx-react-grid-bootstrap3';
import Chip from 'material-ui/Chip';
import ProductsComponentsOfLibrary
from '../../../services/dependencyManager/database/LoadProductsAndComponentsUsingLibrary';
import LoadingScreen from '../Common/LoadingScreen';
const columns = [
{ name: 'Number', title: '' },
{ name: 'ProductName', title: 'The Product Name' },
{ name: 'ProductVersion', title: 'The Product Version' },
{ name: 'ProductLevelDependency', title: 'Product Level Dependency' },
{ name: 'ComponentName', title: 'Component Name' },
{ name: 'ComponentVersion', title: 'Component Version' },
{ name: 'ComponentType', title: 'Component Type' },
];
export default class ProductsAndComponentsForLibrary extends React.PureComponent {
/**
* #class ProductsForLibrary
* #extends {Component}
* #param {any} props props for constructor
* #description Sample React component
*/
constructor(props) {
super(props);
this.state = {
tRows: [],
showTable: false,
columnWidths: {
Number: 100,
ProductName: 350,
ProductVersion: 160,
ProductLevelDependency: 200,
ComponentName: 400,
ComponentVersion: 200,
ComponentType: 200,
},
expandedRows: [],
libraryName: '',
libraryVersion: '',
loading: '',
numberOfRecords: 0,
};
this.loadTable = this.loadTable.bind(this);
}
componentWillReceiveProps(props) {
if (props.renderCondition) {//eslint-disable-line
this.setState({
libraryName: props.nameLibrary,//eslint-disable-line
libraryVersion: props.versionLibrary,//eslint-disable-line
numberOfRecords: 0,
showTable: false,
});
this.loadTable(props.nameLibrary, props.versionLibrary);
}
}
/**
* Load Products and Components using the given library
*/
loadTable(lName, lVersion) {
ProductsComponentsOfLibrary.getProductsAndComponentsUsingLibrary(lName, lVersion).then((response) => {
let i = 0;
const array = [];
if (response.data.length > 0) {
for (i; i < response.data.length; i++) {
array[i] = {
Number: ++i,
ProductName: response.data[--i].PRODUCT_NAME,
ProductVersion: response.data[i].PRODUCT_VERSION,
ProductLevelDependency: response.data[i].PRODUCT_LEVEL_DEPENDENCY,
ComponentName: response.data[i].COMPONENT_NAME,
ComponentVersion: response.data[i].COMP_VERSION,
ComponentType: response.data[i].COMP_TYPE,
};
}
} else {
array[0] = 'No results';
}
this.setState({
tRows: array,
numberOfRecords: response.data.length,
showTable: true,
});
});
}
render() {
let returnView;
if (this.props.renderCondition) {
if (this.state.showTable) {
returnView = (
<div>
{this.state.numberOfRecords > 0 ?
<div>
<div>
<Chip>
{this.state.numberOfRecords} results are returned
</Chip>
</div>
<Grid
rows={this.state.tRows}
columns={columns}
>
<PagingState
defaultCurrentPage={0}
pageSize={12}
/>
<LocalPaging />
<Table />
<TableColumnResizing defaultColumnWidths={this.state.columnWidths} />
<TableHeaderRow allowResizing />
<PagingPanel />
</Grid>
</div>
:
<Chip>
No Libraries Found
</Chip>
}
</div>
);
} else {
returnView = (
<LoadingScreen />
);
}
}
return (
<div>
{returnView}
</div>
);
}
}
Check what version of Grid and React installed. The dx-react-grid-bootstrap3 version ^1.0.0-beta.1 is compatible with react 15 while beta.2 requires react 16.
I had the same problem and fixed it by changing my package.json from this:
"#devexpress/dx-react-core": "^1.0.0-beta.1",
"#devexpress/dx-react-grid": "^1.0.0-beta.1",
"#devexpress/dx-react-grid-bootstrap3": "^1.0.0-beta.1",
to this:
"#devexpress/dx-react-core": "1.0.0-beta.1",
"#devexpress/dx-react-grid": "1.0.0-beta.1",
"#devexpress/dx-react-grid-bootstrap3": "1.0.0-beta.1",
and then after npm install it works fine (with React v15).
Actually It worked when I used VirtualTableView instead of Table from '#devexpress/dx-react-grid-bootstrap3' together with your alteration #ischenkodv

Resources