forked from DevExpress/devextreme-reactive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-grid-bootstrap4): support the bootstrap4 theme (DevExpress…
- Loading branch information
1 parent
3c2d58d
commit c3d58f0
Showing
138 changed files
with
5,818 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...-react-demos/src/demo-sources/grid-column-chooser/disable-toggling-column-visibility.jsxt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
packages/dx-react-demos/src/demo-sources/grid-data-types/bootstrap4/editors.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import * as React from 'react'; | ||
import { | ||
DataTypeProvider, | ||
EditingState, | ||
} from '@devexpress/dx-react-grid'; | ||
import { | ||
Grid, | ||
Table, | ||
TableHeaderRow, | ||
TableEditRow, | ||
TableEditColumn, | ||
} from '@devexpress/dx-react-grid-bootstrap4'; | ||
|
||
import { | ||
generateRows, | ||
globalSalesValues, | ||
} from '../../../demo-data/generator'; | ||
|
||
const getRowId = row => row.id; | ||
|
||
const BooleanFormatter = ({ value }) => | ||
<span className="badge badge-secondary">{value ? 'Yes' : 'No'}</span>; | ||
|
||
const BooleanEditor = ({ value, onValueChange }) => ( | ||
<select | ||
className="form-control" | ||
value={value} | ||
onChange={e => onValueChange(e.target.value === 'true')} | ||
> | ||
<option value={false}>No</option> | ||
<option value>Yes</option> | ||
</select> | ||
); | ||
|
||
const BooleanTypeProvider = props => ( | ||
<DataTypeProvider | ||
formatterComponent={BooleanFormatter} | ||
editorComponent={BooleanEditor} | ||
{...props} | ||
/> | ||
); | ||
|
||
export default class Demo extends React.PureComponent { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
columns: [ | ||
{ name: 'customer', title: 'Customer' }, | ||
{ name: 'product', title: 'Product' }, | ||
{ name: 'units', title: 'Units' }, | ||
{ name: 'shipped', title: 'Shipped' }, | ||
], | ||
booleanColumns: ['shipped'], | ||
rows: generateRows({ | ||
columnValues: { id: ({ index }) => index, ...globalSalesValues }, | ||
length: 8, | ||
}), | ||
}; | ||
|
||
this.commitChanges = ({ added, changed, deleted }) => { | ||
let { rows } = this.state; | ||
if (added) { | ||
const startingAddedId = (rows.length - 1) > 0 ? rows[rows.length - 1].id + 1 : 0; | ||
rows = [ | ||
...rows, | ||
...added.map((row, index) => ({ | ||
id: startingAddedId + index, | ||
...row, | ||
})), | ||
]; | ||
} | ||
if (changed) { | ||
rows = rows.map(row => (changed[row.id] ? { ...row, ...changed[row.id] } : row)); | ||
} | ||
if (deleted) { | ||
const deletedSet = new Set(deleted); | ||
rows = rows.filter(row => !deletedSet.has(row.id)); | ||
} | ||
this.setState({ rows }); | ||
}; | ||
} | ||
render() { | ||
const { rows, columns, booleanColumns } = this.state; | ||
|
||
return ( | ||
<div className="card"> | ||
<Grid | ||
rows={rows} | ||
columns={columns} | ||
getRowId={getRowId} | ||
> | ||
<BooleanTypeProvider | ||
for={booleanColumns} | ||
/> | ||
<EditingState | ||
onCommitChanges={this.commitChanges} | ||
defaultEditingRowIds={[0]} | ||
/> | ||
<Table /> | ||
<TableHeaderRow /> | ||
<TableEditRow /> | ||
<TableEditColumn | ||
showAddCommand | ||
showEditCommand | ||
showDeleteCommand | ||
/> | ||
</Grid> | ||
</div> | ||
); | ||
} | ||
} |
Oops, something went wrong.