Skip to content

Commit 6665a21

Browse files
committed
Fixing issues in base property copying and handling dataSource change for combo.
1 parent dcc0979 commit 6665a21

File tree

4 files changed

+31
-24
lines changed

4 files changed

+31
-24
lines changed

samples/igGrid-TopLevelOpts/igGrid-TopLevelOptsTemplate.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[height]='h'
99
[autoGenerateColumns]='false'
1010
[columns]='cols'
11-
[primaryKey]='"key"'
11+
[primaryKey]='pKey'
1212
></ig-grid>
1313
</div>
1414
</div>

src/igcombo/igcombo.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ export class IgComboComponent extends IgControlBase<IgCombo> implements ControlV
7979
}
8080

8181
dataSourceApplyChanges(changes) {
82+
//dataSource has changed.
8283
const element = jQuery(this._el);
83-
element.data("igCombo").dataBind();
84+
if (element[this._widgetName]) {
85+
element[this._widgetName]("option", "dataSource", this.dataSource);
86+
}
8487
if (this.model && this.model.value) {
8588
this.writeValue(this.model.value);
8689
}
@@ -103,9 +106,9 @@ export class IgComboComponent extends IgControlBase<IgCombo> implements ControlV
103106
try {
104107
this._differ = this._differs.find(value).create();
105108
this._changes = [];
106-
for(var i=0; i < this.dataSource.length; i++){
109+
for (var i=0; i < this.dataSource.length; i++) {
107110
this._changes.push(this.kvalDiffers.find({}).create());
108-
}
111+
}
109112
}
110113
catch(e){
111114
throw new Error("Only binding to arrays is supported.");

src/igcontrolbase/igcontrolbase.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,37 @@ export class IgControlBase<Model> implements DoCheck {
9494

9595
ngOnInit() {
9696
var evtName;
97+
let that = this;
9798
this._events = new Map<string, string>();
9899

99100
for (var opt in jQuery.ui[this._widgetName].prototype.options) {
100101
//copy root level options into this.options
101-
if(this[opt]){
102+
if(this[opt] && typeof this[opt] !== "function"){
102103
this.options[opt] = this[opt];
103104
}
104-
if(opt !== "dataSource") {
105-
Object.defineProperty(this, opt, {
106-
set: this.createSetter(opt),
107-
enumerable: true,
108-
configurable: true
109-
});
110-
}
111105
}
112-
//events binding
113-
let that = this;
114106

107+
for (var opt in jQuery.ui[this._widgetName].prototype.options) {
108+
if(opt !== "dataSource") {
109+
Object.defineProperty(this, opt, {
110+
set: this.createSetter(opt),
111+
enumerable: true,
112+
configurable: true
113+
});
114+
}
115+
}
116+
117+
var propNames = Object.getOwnPropertyNames(jQuery.ui[this._widgetName].prototype);
118+
for(var i = 0; i < propNames.length; i++) {
119+
var name = propNames[i];
120+
if(name.indexOf("_") !== 0 && typeof jQuery.ui[this._widgetName].prototype[name] === "function"
121+
&& name !== "dataSource"){
122+
Object.defineProperty(that, name, {
123+
get: that.createMethodGetter(name)
124+
});
125+
}
126+
}
127+
//events binding
115128
for (var propt in jQuery.ui[this._widgetName].prototype.events) {
116129
evtName = this._widgetName.toLowerCase() + propt.toLowerCase();
117130
this._events[evtName] = propt;
@@ -120,16 +133,6 @@ export class IgControlBase<Model> implements DoCheck {
120133
emmiter.emit({ event: evt, ui: ui });
121134
});
122135
}
123-
var propNames = Object.getOwnPropertyNames(jQuery.ui[this._widgetName].prototype);
124-
for(var i = 0; i < propNames.length; i++) {
125-
var name = propNames[i];
126-
if(name.indexOf("_") !== 0 && typeof jQuery.ui[this._widgetName].prototype[name] === "function"
127-
&& name !== "dataSource"){
128-
Object.defineProperty(that, name, {
129-
get: that.createMethodGetter(name)
130-
});
131-
}
132-
}
133136

134137
if (this.changeDetectionInterval === undefined || this.changeDetectionInterval === null) {
135138
this.changeDetectionInterval = 500;

tests/unit/igcombo/combo.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export function main() {
190190
});
191191
TestBed.compileComponents().then(() => {
192192
let fixture = TestBed.createComponent(TestComponent);
193+
fixture.detectChanges();
193194
fixture.componentInstance.data = fixture.componentInstance.northwind;
194195
setTimeout(function () {
195196
fixture.detectChanges();

0 commit comments

Comments
 (0)