@@ -2,6 +2,7 @@ import React from 'react';
22import { Grid , GridColumn as Column } from '@progress/kendo-react-grid' ;
33import { Sparkline } from '@progress/kendo-react-charts' ;
44import { process } from '@progress/kendo-data-query' ;
5+ import { Checkbox } from '@progress/kendo-react-inputs' ;
56
67class 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+
1424export 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