@@ -30,10 +30,16 @@ type User = {
3030 priority : string ;
3131 email : string ;
3232 avatar : string ;
33+ address : {
34+ city : string ;
35+ country : string ;
36+ } ;
3337} ;
3438
3539const choices = [ 'low' , 'standard' , 'high' ] ;
3640const themes = [ 'bootstrap' , 'material' , 'fluent' , 'indigo' ] ;
41+ const cities = [ 'New York' , 'Los Angeles' , 'Chicago' , 'Houston' , 'Phoenix' , 'London' , 'Paris' , 'Berlin' , 'Tokyo' , 'Sydney' ] ;
42+ const countries = [ 'USA' , 'USA' , 'USA' , 'USA' , 'USA' , 'UK' , 'France' , 'Germany' , 'Japan' , 'Australia' ] ;
3743
3844function getElement < T > ( qs : string ) : T {
3945 return document . querySelector ( qs ) as T ;
@@ -42,8 +48,9 @@ function getElement<T>(qs: string): T {
4248function generateData ( length : number ) : User [ ] {
4349 return Array . from (
4450 { length } ,
45- ( _ , idx ) =>
46- ( {
51+ ( _ , idx ) => {
52+ const cityIndex = getRandomInt ( cities . length ) ;
53+ return {
4754 id : idx ,
4855 name : `User - ${ getRandomInt ( length ) } ` ,
4956 age : getRandomInt ( 100 ) ,
@@ -52,7 +59,12 @@ function generateData(length: number): User[] {
5259 priority : oneOf ( choices ) ,
5360 email : `user${ idx } @org.com` ,
5461 avatar : getAvatar ( ) ,
55- } ) as User ,
62+ address : {
63+ city : cities [ cityIndex ] ,
64+ country : countries [ cityIndex ] ,
65+ } ,
66+ } as User ;
67+ } ,
5668 ) ;
5769}
5870
@@ -162,6 +174,18 @@ const columns: ColumnConfiguration<User>[] = [
162174 {
163175 field : 'email' ,
164176 } ,
177+ {
178+ field : 'address.city' ,
179+ header : 'City' ,
180+ sortable : true ,
181+ filterable : true ,
182+ } ,
183+ {
184+ field : 'address.country' ,
185+ header : 'Country' ,
186+ sortable : true ,
187+ filterable : true ,
188+ } ,
165189 {
166190 field : 'subscribed' ,
167191 dataType : 'boolean' ,
0 commit comments