Posted 14 September 2017, 2:14 am EST
Sorry Manish. Please ignore my previous question. I have found a work around. What I did was calling the setGridGrouping twice and it is working. Again. Thank you Manish.
Here is what I did:
getData() {
this.showLoading(‘Loading, please wait…’);
this.proCastDataSub = this.proCastData.loadData(this.baseUrl + this.queryParams)
.subscribe((pd: any) => {
this.dataCollection = new wjCore.CollectionView(pd);
this.dataCollection.filter = this._filterFunction.bind(this);
this.filterData = this.dataCollection;
this.dataCollection.collectionChanged.addHandler((s: wjCore.CollectionView, e: wjCore.EventArgs) => {
let groupDesc = this.filterData.groupDescriptions;
this.filterData = wjCore.asCollectionView(s.items);
if (this.initLoad === false) {
this.setGridGrouping();
this.initLoad = true;
} else {
if (groupDesc.length > 0 ) {
this.filterData.groupDescriptions.clear();
for (let i = 0; i < groupDesc.length; i++) {
if (this.findGroupDescription(groupDesc[i].propertyName) === false) {
this.filterData.groupDescriptions.push(new wjCore.PropertyGroupDescription(groupDesc[i].propertyName));
}
}
}
}
});
this.setGridGrouping();
},
(error) => this.errorMessage = < any > error,
() => this.dismmisLoading()
);
}
setGridGrouping(): void {
let groupBy = ‘Superintendent’; // default group by
if (Library.isNullOrUndefined(this.currentUserView.viewData) === false && Library.isNullOrUndefined(this.currentUserView.viewData.groupBy) === false) {
groupBy = this.currentUserView.viewData.groupBy === ‘Sup’ ? ‘Superintendent’ : ‘TeamLeader’;
}
this.pushGroupDescription('BusinessUnitCode,' + groupBy);
}