我正在研究有角度的ngx-datatables,在这里我需要实现其列重排序功能。但是它不起作用(没有出现任何错误),并且拖动行时列的宽度也没有改变。
我在angular.json文件的css文件下面添加了。是否需要任何js文件?
“ node_modules/@swimlane/ngx-datatable/release/components/datatable.component.css”,
“ node_modules/@swimlane/ngx-datatable/release/themes/material.css”,
“ node_modules/@swimlane/ngx-datatable/release/themes/dark.css”,
“ node_modules/@swimlane/ngx-datatable/release/assets/icons.css”
我正在跟踪this链接。
@Component({
selector: 'app-my-component',
styles: [`
.icon {
position:absolute;
}
.datatable-icon-down {
top: 0px;
}
.datatable-icon-up {
top: 40px;
}
.dragFromLeft .icon {
left:-13px;
}
`],
template: `
<div>
<ngx-datatable
class="material"
[rows]="rows"
[columnMode]="'force'"
[headerHeight]="50"
[footerHeight]="50"
[rowHeight]="'auto'"
[externalPaging]="true"
[externalSorting]="true"
[count]="page.count"
[offset]="page.offset"
[limit]="page.limit"
[sortType]="'single'"
(page)="pageCallback($event)"
(sort)="sortCallback($event)"
[reorderable]="reorderable"
[swapColumns]="swapColumns"
[targetMarkerTemplate]="targetMarkerTemplate"
[loadingIndicator]="loadingIndicator" >
<ngx-datatable-column
*ngFor="let col of columns"
[name]="col.name" [prop]="col.prop">
</ngx-datatable-column>
</ngx-datatable>
<ng-template #targetMarkerTemplate let-class="class">
<div [ngClass]="class">
<div class="icon datatable-icon-down"></div>
<div class="icon datatable-icon-up"></div>
</div>
</ng-template>
<div class='selected-column'>
<h4>Available Columns</h4>
<ul>
<li *ngFor='let col of allcolumns'>
<input
type='checkbox'
[id]="col.name"
(click)='toggle(col)'
[checked]='isChecked(col)'
/>
<label [attr.for]="col.name">{{col.name}}</label>
</li>
</ul>
</div>
</div>
`
})
export class NGXServerSide implements OnInit {
rows: Object[] = [];
loadingIndicator: boolean = false;
reorderable: boolean = true;
swapColumns: boolean = false;
columns = [
{ name: 'EmployeeId', prop: 'EmployeeId' },
{ name: 'Name', prop: 'Name' },
{ name: 'City', prop: 'City' },
{ name: 'Department', prop: 'Department', sortable: false },
{ name: 'Gender', prop: 'Gender', sortable: false },
];
allcolumns = [
{ name: 'EmployeeId', prop: 'EmployeeId' },
{ name: 'Name', prop: 'Name' },
{ name: 'City', prop: 'City' },
{ name: 'Department', prop: 'Department', sortable: false },
{ name: 'Gender', prop: 'Gender', sortable: false },
]