Posted 10 July 2018, 12:48 am EST
Hi,
Thanks for providing the sample.
To sort the column with the value of label1+label2 , you may use sortConverter property of collection view and assign a function to which return the value of each item that is used for sort comparison.
Please refer to following code snippet
/* assign sortMemberPath to identify this col */
<wj-flex-grid-column [header]="'label1 + label2'" [binding]="'label1' [sortMemberPath]="'colWithTemplate'" >
.....template goes here
</wj-flex-grid-column>
/* in grid initialized method, assign sort converter */
initGrid(grid){
(grid.collectionView as wjCore.CollectionView).sortConverter=(sd,item,value)=>{
if(sd.property="colWithTemplate"){
return item.label1+item.label2;/*text that will be used for sort comparisons*/
}
return value;
}
}
More info on sortConverter:-http://demos.wijmo.com/5/Angular/WijmoHelp/WijmoHelp/topic/wijmo.collections.CollectionView.Class.html#sortConverter
More info on sortMemberPath:-http://demos.wijmo.com/5/Angular/WijmoHelp/WijmoHelp/topic/wijmo.grid.Column.Class.html#sortMemberPath
You may also set sortComparer property if you want to implement your own compare logic. Please Refer the following for more info:-
http://demos.wijmo.com/5/Angular/WijmoHelp/WijmoHelp/topic/wijmo.collections.CollectionView.Class.html#sortComparer
For resizing rows you may use autoSizeRows() method of flexgrid.
Please refer to following code snippet:
/*first set autoSizeRows property to false for wjFlexGridTemplate */
<ng-template [autoSizeRows]="false"
wjFlexGridCellTemplate
[cellType]="'Cell'"
let-item="item">
{{item.label1}}<br *ngIf="item.label1&&item.label2">{{item.label2}}
</ng-template>
/* then resize rows on grid init and loaded rows event */
<wj-flex-grid #grid (initialized)="init(grid)" (loadedRows)="gridRowsLoaded(grid)">
....grid columns
</wj-flex-grid>
/* equivalent init and gridRowsLoaded methods */
init(grid){
grid.autoSizeRows();
}
gridRowsLoaded(grid){
grid.autoSizeRows();
}
Link to updated sandbox:-https://codesandbox.io/s/yvl4j5lp0v
P.S. Don’t forget to set column binding for autoSizeRows() to work properly.
~Manish