Skip to content

Commit 40e746b

Browse files
committed
chore: update grid props in kendo-react-sales-dashboard app
1 parent af0346f commit 40e746b

File tree

2 files changed

+23
-31
lines changed

2 files changed

+23
-31
lines changed

examples/kendo-react-sales-dashboard/src/App.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ class App extends Component {
8282
let headerText = this.state.value.replace('Sales','');
8383
return (
8484
<Ripple>
85-
<div className="buttons-right mt-1">
86-
<Button themeColor={'primary'} onClick={this.handleShare} className='mr-2'>Share</Button>
87-
<Button onClick={this.handlePDFExport}>Export to PDF</Button>
88-
</div>
8985
<div className="app-container" ref={(app) => this.app = app}>
9086
<div className="row">
9187
<div className="col-xs-9 col-sm-9 col-md-9 col-lg-9 col-xl-9">
9288
<h1>Sales | {headerText}</h1>
93-
</div>
89+
</div>
90+
<div className="buttons-right mt-1">
91+
<Button themeColor={'primary'} onClick={this.handleShare} className='mr-2'>Share</Button>
92+
<Button onClick={this.handlePDFExport}>Export to PDF</Button>
93+
</div>
9494
</div>
9595
<div className="row">
9696
<div className="col-xs-3 col-sm-3 col-md-3 col-lg-3 col-xl-3">

examples/kendo-react-sales-dashboard/src/components/GridContainer.jsx

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { Grid, GridColumn as Column } from '@progress/kendo-react-grid';
33
import { Sparkline } from '@progress/kendo-react-charts';
4-
import { process } from '@progress/kendo-data-query';
4+
import { Checkbox } from '@progress/kendo-react-inputs';
55

66
class SparkLineChartCell extends React.Component {
77
render (){
@@ -11,52 +11,44 @@ class SparkLineChartCell extends React.Component {
1111
}
1212
}
1313

14+
class ActiveCell extends React.Component {
15+
render() {
16+
console.log(this.props.dataItem);
17+
return (
18+
<td><Checkbox disabled defaultChecked={this.props.dataItem[this.props.field]} /></td>
19+
)
20+
}
21+
}
22+
1423
export default class GridContainer extends React.Component {
1524

16-
state = {
17-
dataState:{
18-
sort:[{
19-
field: "UnitPrice",
20-
dir:"asc"
21-
}]
22-
}
23-
}
2425
processData = (data) => {
2526
data.forEach(item => {
2627
item.PriceHistory = Array.from({length: 40}, () => Math.floor(Math.random() * 100));
2728
return item
2829
})
29-
return process(data,this.state.dataState);
30+
return data;
3031
}
3132

32-
handleDataStateChange = (e) => {
33-
this.setState({
34-
dataState: e.dataState
35-
})
36-
}
3733

3834
render() {
3935
return (
4036
<div>
4137
<Grid
4238
style={{ height: '300px' }}
4339
data={this.processData(this.props.data)}
44-
{...this.state.dataState}
45-
onDataStateChange={this.handleDataStateChange}
40+
defaultSort={[{
41+
field: "UnitPrice",
42+
dir:"asc"
43+
}]}
4644
sortable
4745
>
4846
<Column field="ProductID" title="ID" sortable={false} width="40px"/>
49-
<Column field="ProductName" title="Name" />
47+
<Column field="ProductName" title="Name" />
5048
<Column field="UnitPrice" title="Price" width="100px" />
5149
<Column field="UnitsInStock" title="In stock" sortable={false} width="100px"/>
52-
<Column field="PriceHistory" title="Price history" cell={SparkLineChartCell}sortable={false} width="200px"/>
53-
<Column field="Discontinued" title="Active" sortable={false} width="100px"
54-
cell={(props) => (
55-
<td>
56-
<input type="checkbox" disabled className="k-checkbox" defaultChecked={props.dataItem[props.field]} />
57-
<label className="k-checkbox-label"></label>
58-
</td>
59-
)} />
50+
<Column field="PriceHistory" title="Price history" cells={{ data: SparkLineChartCell }} sortable={false} width="200px"/>
51+
<Column field="Discontinued" title="Active" sortable={false} width="70px" cells={{ data: ActiveCell }} />
6052
</Grid>
6153
</div>
6254
);

0 commit comments

Comments
 (0)