@@ -65,13 +65,54 @@ module IgUtil {
6565 }
6666 return options ;
6767 }
68+
69+ export function extractAllGridColumnProperties ( ) {
70+ return [ 'headerText' , 'key' , 'formatter' , 'format' , 'dataType' , 'width' , 'hidden' , 'template' , 'unbound' , 'group' , 'rowspan' , 'formula' , 'unboundValues' , 'unboundValuesUpdateMode' , 'headerCssClass' , 'columnCssClass' ] ;
71+ }
6872}
6973
7074@Directive ( {
7175 selector : 'column' ,
72- inputs : [ 'headerText' , 'key' , 'formatter' , 'format' , 'dataType' , 'width' , 'hidden' , 'template' , 'unbound' , 'group' , 'rowspan' , 'formula' , 'unboundValues' , 'unboundValuesUpdateMode' , 'headerCssClass' , 'columnCssClass' ]
76+ inputs : IgUtil . extractAllGridColumnProperties ( )
7377} )
74- export class Column { }
78+ export class Column {
79+ private _settings : any = { } ;
80+ private _el : any ;
81+
82+ constructor ( el : ElementRef ) {
83+ this . _el = el ;
84+ let self = this ;
85+ let i , settings = IgUtil . extractAllGridColumnProperties ( ) ;
86+ for ( i = 0 ; i < settings . length ; i ++ ) {
87+ Object . defineProperty ( self , settings [ i ] , {
88+ set : self . createColumnsSetter ( settings [ i ] ) ,
89+ get : self . createColumnsGetter ( settings [ i ] ) ,
90+ enumerable : true ,
91+ configurable : true
92+ } ) ;
93+ }
94+ }
95+
96+ createColumnsSetter ( name ) {
97+ return function ( value ) {
98+ let grid = jQuery ( this . _el . nativeElement . parentElement ) . find ( "table[role='grid']" ) ;
99+ this . _settings [ name ] = value ;
100+
101+ if ( jQuery . ui [ "igGrid" ] &&
102+ jQuery . ui [ "igGrid" ] . prototype . options &&
103+ jQuery . ui [ "igGrid" ] . prototype . options . hasOwnProperty ( "columns" ) &&
104+ grid . data ( "igGrid" ) ) {
105+ grid [ "igGrid" ] ( "option" , "columns" , this . _settings ) ;
106+ }
107+ }
108+ }
109+
110+ createColumnsGetter ( name ) {
111+ return function ( ) {
112+ return this . _settings [ name ] ;
113+ }
114+ }
115+ }
75116
76117@Directive ( {
77118 selector : 'feature' ,
@@ -81,12 +122,10 @@ export class Column {}
81122export class Feature {
82123 private _el : any ;
83124 private _settings : any = { } ;
84- @Input ( ) public name : string ;
85-
86- constructor ( el : ElementRef ) {
87- this . _el = el ;
125+ @Input ( ) set name ( name : string ) {
126+ this . _settings [ "name" ] = name ;
88127 var self = this ;
89- let featureName = "igGrid" + this . name ;
128+ let featureName = "igGrid" + name ;
90129 for ( var setting in jQuery . ui [ featureName ] . prototype . options ) {
91130 Object . defineProperty ( self , setting , {
92131 set : self . createFeatureSetter ( setting ) ,
@@ -97,8 +136,12 @@ export class Feature {
97136 }
98137 }
99138
100- ngOnInit ( ) {
101-
139+ get name ( ) :string {
140+ return this . _settings [ "name" ] ;
141+ }
142+
143+ constructor ( el : ElementRef ) {
144+ this . _el = el ;
102145 }
103146
104147 createFeatureSetter ( name ) {
@@ -396,10 +439,10 @@ export class IgGridBase<Model> extends IgControlBase<Model> implements AfterCont
396439
397440 ngAfterContentInit ( ) {
398441 if ( this . _columns . length ) {
399- this . _opts [ "columns" ] = this . _columns . map ( ( c ) => c ) ;
442+ this . _opts [ "columns" ] = this . _columns . map ( ( c ) => c . _settings ) ;
400443 }
401444 if ( this . _features . length ) {
402- this . _opts [ "features" ] = this . _features . map ( ( c ) => c ) ;
445+ this . _opts [ "features" ] = this . _features . map ( ( c ) => c . _settings ) ;
403446 }
404447 super . ngOnInit ( ) ;
405448 }
0 commit comments