我正在创建一个ngx-datatable但在表的标题处获得额外的空间。由于这个标题,数据行也没有与标题对齐。这个额外的空间来自表的两端。
我需要删除下图中标记的空格: https://androidbycode.wordpress.com/2015/06/30/android-ndk-version-code-scheme-for-publishing-apks-per-architecture/
HTML:
<ngx-datatable class='bootstrap' columnMode="force" [headerHeight]="30" [selectionType]="'multiClick'"
[rows]="rows">
<ngx-datatable-column name="UserName" prop = "UserName" headerClass="mydata-table-header">
</ngx-datatable-column>
<ngx-datatable-column name="Date" prop = "Date" headerClass="mydata-table-header" >
</ngx-datatable-column>
<ngx-datatable-column name="Activity" prop="Activity" headerClass="mydata-table-header" ></ngx-datatable-column>
<ngx-datatable-column name="Decision" prop="Activity" headerClass="mydata-table-header" >
</ngx-datatable-column>
<ngx-datatable-column name="Remark" prop="Activity" headerClass="mydata-table-header">
</ngx-datatable-column>
CSS:
.ngx-datatable.bootstrap {
box-shadow: none;
font-size: 13px;
border:none;
border-collapse: collapse;
}
.ngx-datatable.bootstrap .datatable-header {
height: unset !important;
background-color:#28998b;
}
.ngx-datatable.bootstrap .datatable-header .datatable-header-cell {
vertical-align: bottom;
padding: 0.75rem;
border-bottom: 1px solid #000000;
border-left: 1px solid #000;
border-right: 1px solid #000;
}
.ngx-datatable.bootstrap .datatable-header .datatable-header-cell .datatable-header-cell-label {
line-height: 24px;
}
.ngx-datatable.bootstrap .datatable-body {
}
.ngx-datatable.bootstrap .datatable-body .datatable-body-row {
vertical-align: top;
border-top: 1px solid #000000;
}
.ngx-datatable.bootstrap .datatable-body .datatable-body-row.datatable-row-even {
background-color: rgba(0, 0, 0, 0.05);
}
.ngx-datatable.bootstrap .datatable-body .datatable-body-row .datatable-body-cell {
text-align: left;
vertical-align: top;
border-left: 1px solid #000;
border-right: 1px solid #000;
}
.ngx-datatable.bootstrap .datatable-body .datatable-body-row.active {
background-color: #1483ff;
color: #FFF;
}
答案 0 :(得分:1)
您的css文件如下所示:
.datatable-header {
height: unset !important;
}
.ngx-datatable.bootstrap .datatable-header .datatable-header-cell {
vertical-align: bottom;
padding: 0.0rem !important;
border-bottom: 1px solid #000000;
border-left: 1px solid #000;
border-right: 1px solid #000;
background-color:#28998b;
}
.ngx-datatable.bootstrap .datatable-body .datatable-body-row .datatable-body-cell {
text-align: left;
vertical-align: top;
border-left: 1px solid #000;
border-right: 1px solid #000;
}
您可能需要调整填充中的值:0.0rem。
另外,请确保您的自定义css是styleUrls元数据中的最后一行:
styleUrls: [
'../../../node_modules/@swimlane/ngx-datatable/release/themes/bootstrap.css',
'./your.component.css'
]
答案 1 :(得分:0)
如果您使用有角度的功能(它可以工作,但这是一种HACK!):
:host ::ng-deep .ngx-datatable.bootstrap .datatable-header,
:host ::ng-deep .datatable-header {
height: 30px !important; // set the height of the header
}
:host ::ng-deep .ngx-datatable.bootstrap .datatable-header .datatable-header-cell {
font-weight: bold;
padding: 0 0 0 10px !important; // align the header text
}
答案 2 :(得分:0)
您可以在ngx-datatable-column标签上尝试以下属性:
[width]="150"
[height]="100"
[canAutoResize]="false"
这比使用css类要简单,但是您仍然可以创建css类,由您自己决定,希望这对有疑问的人有所帮助。