@@ -2,8 +2,11 @@ import React from 'react';
22import { Grid , GridColumn as Column } from '@progress/kendo-react-grid' ;
33import { gridData } from '../data/appData' ;
44import { Sparkline } from '@progress/kendo-react-charts' ;
5+ import { Checkbox } from '@progress/kendo-react-inputs' ;
6+
7+ const SparkLineChartCell = ( props ) => < td > < Sparkline data = { props . dataItem . PriceHistory } /> </ td >
8+ const ActiveCell = ( props ) => < td > < Checkbox disabled defaultChecked = { props . dataItem [ props . field ] } /> </ td >
59
6- const SparkLineChartCell = ( props ) => < td > < Sparkline data = { props . dataItem . PriceHistory } /> </ td >
710const processData = ( data ) => {
811 data . forEach ( ( item ) => {
912 item . PriceHistory = Array . from ( { length : 20 } , ( ) => Math . floor ( Math . random ( ) * 100 ) ) ;
@@ -15,20 +18,21 @@ const processData = (data) => {
1518export const GridContainer = ( ) => (
1619
1720 < div >
18- < Grid style = { { height : '300px' } } data = { processData ( gridData ) } >
19- < Column field = "ProductID" title = "ID" width = "40px" />
20- < Column field = "ProductName" title = "Name" width = "160px" />
21- < Column field = "Category.CategoryName" title = "Category Name" width = "80px" />
21+ < Grid
22+ style = { { height : '300px' } }
23+ data = { processData ( gridData ) }
24+ defaultSort = { [ {
25+ field : "UnitPrice" ,
26+ dir :"asc"
27+ } ] }
28+ sortable
29+ >
30+ < Column field = "ProductID" title = "ID" width = "40px" sortable = { false } />
31+ < Column field = "ProductName" title = "Name" />
2232 < Column field = "UnitPrice" title = "Price" width = "80px" />
23- < Column field = "UnitsInStock" title = "Stock" width = "90px" />
24- < Column field = "PriceHistory" width = "130px" cell = { SparkLineChartCell } title = "Price history" />
25- < Column field = "Discontinued" width = "130px"
26- cell = { ( props ) => (
27- < td >
28- < input className = "k-checkbox" type = "checkbox" disabled defaultChecked = { props . dataItem [ props . field ] } />
29- < label className = "k-checkbox-label" > </ label >
30- </ td >
31- ) } />
33+ < Column field = "UnitsInStock" title = "In stock" width = "100px" sortable = { false } />
34+ < Column field = "PriceHistory" title = "Price history" width = "200px" cells = { { data : SparkLineChartCell } } sortable = { false } />
35+ < Column field = "Discontinued" title = "Active" width = "70px" cells = { { data : ActiveCell } } sortable = { false } />
3236 </ Grid >
3337 </ div >
3438) ;
0 commit comments