@@ -53,12 +53,75 @@ var NODES = {
5353
5454const _reflect : any = Reflect ;
5555
56+ module IgUtil {
57+ export function extractAllGridFeatureOptions ( ) {
58+ let allWidgets = jQuery . ui ;
59+ let options = [ "name" ] ;
60+ let widget : any ;
61+ for ( widget in allWidgets ) {
62+ if ( widget . substring ( 0 , 6 ) === "igGrid" && widget !== "igGrid" ) {
63+ options = options . concat ( Object . keys ( jQuery . ui [ widget ] . prototype . options ) ) ;
64+ }
65+ }
66+ return options ;
67+ }
68+ }
69+
5670@Directive ( {
5771 selector : 'column' ,
5872 inputs : [ 'headerText' , 'key' , 'formatter' , 'format' , 'dataType' , 'width' , 'hidden' , 'template' , 'unbound' , 'group' , 'rowspan' , 'formula' , 'unboundValues' , 'unboundValuesUpdateMode' , 'headerCssClass' , 'columnCssClass' ]
5973} )
60- export class Column {
61- key :string ;
74+ export class Column { }
75+
76+ @Directive ( {
77+ selector : 'feature' ,
78+ inputs : IgUtil . extractAllGridFeatureOptions ( )
79+ } )
80+
81+ export class Feature {
82+ private _el : any ;
83+ private _settings : any = { } ;
84+ @Input ( ) public name : string ;
85+
86+ constructor ( el : ElementRef ) {
87+ this . _el = el ;
88+ var self = this ;
89+ let featureName = "igGrid" + this . name ;
90+ for ( var setting in jQuery . ui [ featureName ] . prototype . options ) {
91+ Object . defineProperty ( self , setting , {
92+ set : self . createFeatureSetter ( setting ) ,
93+ get : self . createFeatureGetter ( setting ) ,
94+ enumerable : true ,
95+ configurable : true
96+ } ) ;
97+ }
98+ }
99+
100+ ngOnInit ( ) {
101+
102+ }
103+
104+ createFeatureSetter ( name ) {
105+ return function ( value ) {
106+ let grid = jQuery ( this . _el . nativeElement . parentElement ) . find ( "table[role='grid']" ) ;
107+ let featureName = "igGrid" + this . name ;
108+ this . _settings [ name ] = value ;
109+
110+ if ( this . name !== undefined && this . name !== null &&
111+ jQuery . ui [ featureName ] &&
112+ jQuery . ui [ featureName ] . prototype . options &&
113+ jQuery . ui [ featureName ] . prototype . options . hasOwnProperty ( name ) &&
114+ grid . data ( featureName ) ) {
115+ grid [ featureName ] ( "option" , name , value ) ;
116+ }
117+ }
118+ }
119+
120+ createFeatureGetter ( name ) {
121+ return function ( ) {
122+ return this . _settings [ name ] ;
123+ }
124+ }
62125}
63126
64127export function IgComponent ( args : any = { } ) {
@@ -321,6 +384,7 @@ export class IgGridBase<Model> extends IgControlBase<Model> implements AfterCont
321384 protected _dataSource : any ;
322385 protected _changes : any ;
323386 @ContentChildren ( Column ) _columns : QueryList < Column > ;
387+ @ContentChildren ( Feature ) _features : QueryList < Feature > ;
324388
325389 constructor ( el : ElementRef , renderer : Renderer , differs : IterableDiffers ) { super ( el , renderer , differs ) ; }
326390
@@ -334,6 +398,9 @@ export class IgGridBase<Model> extends IgControlBase<Model> implements AfterCont
334398 if ( this . _columns . length ) {
335399 this . _opts [ "columns" ] = this . _columns . map ( ( c ) => c ) ;
336400 }
401+ if ( this . _features . length ) {
402+ this . _opts [ "features" ] = this . _features . map ( ( c ) => c ) ;
403+ }
337404 super . ngOnInit ( ) ;
338405 }
339406
0 commit comments