- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想知道是否有可能包含一个包含定义为
cdkDragHandle。目前它在整行上都处于事件状态,但我只希望将单个图标用作draghandle
这是我正在使用的代码的一部分:
<mat-table #table [dataSource]="dataSource" class="mat-elevation-z8"
cdkDropList [cdkDropListData]="dataSource"
(cdkDropListDropped)="dropTable($event)">
<ng-container matColumnDef="Order">
<mat-header-cell *matHeaderCellDef>
Actions
</mat-header-cell>
<mat-cell mat-cell *matCellDef="let element">
<mat-icon class="dragCursor" cdkDragHandle>reorder</mat-icon>
{{element.order}}
<button mat-icon-button (click)="onDeleteClick(element)">
<mat-icon>delete</mat-icon>
</button>
</mat-cell>
</ng-container>
... more column definitions
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;" cdkDrag [cdkDragData]="row" cdkDragLockAxis="y"></mat-row>
最佳答案
看来cdkDragHandle
不适用于mat-table
。
使用最新的Angular Material版本进行测试,v。 9.1.0 。
Github上也讨论了此错误,我在其中找到了以下解决方案:
https://github.com/angular/components/issues/13770#issuecomment-506182564-作者ajp76054
。
我已经在我的项目中使用了它,它似乎工作正常。
我会在这里将其发布给需要它的人:
使用cdkDragDisabled
属性设置为true
初始化表,以禁用整个拖动容器。这允许用户仍然与表格单元格交互,直到它们准备拖动行为止。
然后在拖动 handle 元素(<mat-icon>
)上,使用(mousedown)
事件将cdkDragDisabled
设置为false
。
然后,将其重置为true
事件处理程序中的(cdkDropListDropped)
。
因此,在模板中使用以下代码:
<mat-table
#table
[dataSource]="dataSource"
cdkDropList
(cdkDropListDropped)="drop($event)"
cdkDropListData="dataSource"
[cdkDropListDisabled]="dragDisabled">
...
<ng-container matColumnDef="order">
<mat-header-cell *matHeaderCellDef>Order</mat-header-cell>
<mat-cell *matCellDef="let element">
<mat-icon class="dragCursor" (mousedown)="dragDisabled = false;">reorder</mat-icon>
</mat-cell>
</ng-container>
...
<mat-row *matRowDef="let row; columns: displayedColumns;" cdkDrag [cdkDragData]="row"></mat-row>
</mat-table>
ts
文件中:
export class TableBasicExample {
dragDisabled = true;
drop(event: CdkDragDrop<any[]>) {
// Return the drag container to disabled.
this.dragDisabled = true;
// other code on drop event
//
const previousIndex = this.dataSource.findIndex((d) => d === event.item.data);
moveItemInArray(this.dataSource, previousIndex, event.currentIndex);
this.table.renderRows();
}
}
关于angular - Angular Material 垫台中的cdkDragHandle不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53307611/
我有一个 mat-select 元素,其中包含固定数量的 mat-option 元素。要查看最后一个元素,我必须滚动列表。是否可以扩大区域以便我无需滚动即可看到最后一个元素?
我想填充一些百分比值,以便小数位前始终有 3 个单位。使用整数我可以使用 '%03d' - 是否有等效的 float ? '%.3f' 适用于小数点后,但 '%03f' 什么都不做。 最佳答案 '%0
我有一个 vector Mat 文件,我想将它存储在 txt 文件中。每个 mat 文件的大小为 1x4500,我总共有 5000 个 vector 。我试图用上面的代码存储在 txtfile 中:
我需要一个 Mat 对象,其中每个元素都是一个类型为 double 且大小为 15 的 vector 。 我试过了 Mat seq(rownum,colnum,Vec); 但这给了我错误: expec
我想将我的 OpenCV Mat 转换为 Matlab .mat 文件,Matlab 可以轻松读取该文件。我不想使用Mex函数直接将数据提供给matlab,因为我想将数据保存在硬盘上。 有可用的 cv
我正在使用 当条件为真时,我希望有一些具有粗体样式的选项。 目前,下拉选项中的选项为粗体,但一旦选择该选项,该样式将不会应用于文本字段中的选择。 如何在选择后将样式应用于文本字段? 这是一个代码示例:
我在手机上运行我的应用程序,同时使用 MAT 进行调试。在我尝试在 Eclipse 中转储 HPROF 文件后,出现错误: 无法将 hprof 数据保存到临时文件中。设备上没有剩余空间。 我已经对此进
我有一个 CV_32F 类型的垫子 A 和一个二进制值为 0 和 255 的掩码 M。例如, A = [0.1 0.2; 0.3 0.4] M = [1 0 ; 0 0 ] 我想得到 A
我在我的 Angular 5 应用程序中使用@angular/material。我使用的 Angular Material 版本是 5.0.2。我正在使用@angular/animations 5.1
我想根据任意数据类型、行维度、列维度和 channel 维度的一维数据数组构建一个 3 channel 矩阵。在我的示例中,我有一个 1x12 double 组数据,我想将其转换为 2x2x3 Ope
我正在尝试使用 C# 中的 BouncycaSTLe 解密河豚加密字符串。 我能够轻松地加密和解密我自己的字符串,但不幸的是,我必须解密由另一个系统生成的字符串。 我能够使用以下命令使用 C#/Bou
我想在 Android Opencv c++ 库中获取绝对矩阵。我正在使用 abs(Mat m) 函数,但它会返回 MatExpr 对象。你知道如何只用矩阵的绝对值得到 Mat 对象吗? Ma
在 OpenCV 中,我可以将 RGB 1920 x 1080 垫乘以 3 x 3 垫以更改源垫的颜色组成。一旦我的源垫形状正确,我就可以使用“*”运算符来执行乘法。使用 cv::gpu::GpuMa
给定vector > A_STL , 我希望它被转换成 arma::mat A . 最佳答案 一种简单的方法是将 vector 矩阵的 vector 展平为一维 vector 。因此,您可以使用 ma
以下代码从文件中读取图像到 cv::Mat目的。 #include #include cv::Mat load_image(std::string img_path) { cv::Mat im
我有一个 AVCaptureSession,它输出带有 BGRA 像素的 CMSampleBuffer。我正在尝试仅从 BGR 创建 Mat 对象,以最有效的方式,使用数据 pointers。 CV
我正在尝试诊断我的 Android 应用程序中的内存问题。我转储了一个 HPROF 文件并将其加载到 Eclipse MAT 工具中(参见 How to analyze memory using an
我是一名优秀的程序员,十分优秀!