Skip to content

Commit f4c2459

Browse files
committed
chore: update grid props in kendo-react-sales-dashboard app
1 parent b5e00a3 commit f4c2459

File tree

2 files changed

+23
-30
lines changed

2 files changed

+23
-30
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 & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { Grid, GridColumn as Column } from '@progress/kendo-react-grid';
33
import { Sparkline } from '@progress/kendo-react-charts';
44
import { process } from '@progress/kendo-data-query';
5+
import { Checkbox } from '@progress/kendo-react-inputs';
56

67
class SparkLineChartCell extends React.Component {
78
render (){
@@ -11,52 +12,44 @@ class SparkLineChartCell extends React.Component {
1112
}
1213
}
1314

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

16-
state = {
17-
dataState:{
18-
sort:[{
19-
field: "UnitPrice",
20-
dir:"asc"
21-
}]
22-
}
23-
}
2426
processData = (data) => {
2527
data.forEach(item => {
2628
item.PriceHistory = Array.from({length: 40}, () => Math.floor(Math.random() * 100));
2729
return item
2830
})
29-
return process(data,this.state.dataState);
31+
return data;
3032
}
3133

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

3835
render() {
3936
return (
4037
<div>
4138
<Grid
4239
style={{ height: '300px' }}
4340
data={this.processData(this.props.data)}
44-
{...this.state.dataState}
45-
onDataStateChange={this.handleDataStateChange}
41+
defaultSort={[{
42+
field: "UnitPrice",
43+
dir:"asc"
44+
}]}
4645
sortable
4746
>
4847
<Column field="ProductID" title="ID" sortable={false} width="40px"/>
49-
<Column field="ProductName" title="Name" />
48+
<Column field="ProductName" title="Name" />
5049
<Column field="UnitPrice" title="Price" width="100px" />
5150
<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-
)} />
51+
<Column field="PriceHistory" title="Price history" cells={{ data: SparkLineChartCell }} sortable={false} width="200px"/>
52+
<Column field="Discontinued" title="Active" sortable={false} width="70px" cells={{ data: ActiveCell }} />
6053
</Grid>
6154
</div>
6255
);

0 commit comments

Comments
 (0)