11import React from 'react' ;
22import { Grid , GridColumn as Column } from '@progress/kendo-react-grid' ;
33import { Sparkline } from '@progress/kendo-react-charts' ;
4- import { process } from '@progress/kendo-data-query ' ;
4+ import { Checkbox } from '@progress/kendo-react-inputs ' ;
55
66class 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+
1423export 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