简体   繁体   English

Kendo UI Angular 在不禁用主细节的情况下无法选择网格行

[英]Kendo UI Angular make grid row not selectable without disabling master detail

I am trying to make a row in a Kendo UI grid unselectable.我正在尝试使 Kendo UI 网格中的一行不可选择。

The grid itself is a master detail grid with the following html:网格本身是一个主从网格,具有以下 html:

<kendo-grid 
[kendoGridBinding]="myData" 
[data]="gridData" 
[selectable]="selectableSettings" 
kendoGridSelectBy 
[selectedKeys]="mySelectedKeys"
[rowClass]="isDisabled"
>

<kendo-grid-checkbox-column width="40" [ngClass]="{'k-state-selected': false}">
</kendo-grid-checkbox-column>

<kendo-grid-column field="jobDisplayName" title="Job Display Name">
</kendo-grid-column>

<kendo-grid-column field="nrItems" title="Nr Items in MID">
</kendo-grid-column>

<kendo-grid-column field="status" title="status">
</kendo-grid-column>

<ng-template kendoGridDetailTemplate let-dataItem let-rowIndex="rowIndex">
    <app-ab-status-tasks-grid [tasks]="dataItem.tasks"></app-ab-status-tasks-grid>
</ng-template>
</kendo-grid>

I added a isDisabled function which sets k-state-disabled class我添加了一个 isDisabled function 设置 k-state-disabled class

    public isDisabled(args) {
  return {
       'k-state-disabled': (<ActiveJob>args.dataItem).jobStatus != selectableState
   };  
}

This does make the row unselectable, however it also disables the master detail functionality.这确实使该行不可选择,但它也禁用了主从细节功能。

禁用行

So at 1, it's not possible to click the plus sign and view the detail for this row.因此在 1 处,无法单击加号并查看该行的详细信息。

Is there a way to disable just the checkbox?有没有办法只禁用复选框?

I also found that adding 'disabled' to the checkbox element doesn't work.我还发现将“禁用”添加到复选框元素不起作用。 This is probably because the row itself is still selectable.这可能是因为该行本身仍然是可选的。

With the help of Kendo support there is a solution, so if it can help others here is the setup.在 Kendo 支持的帮助下,有一个解决方案,所以如果它可以帮助其他人,这里就是设置。

Use [rowClass] on the grid and the following function:在网格上使用 [rowClass] 和以下 function:

rowCallback(context: RowClassArgs) {    
  return {        
    'DisableRowSelection': !canBeOveridden
  };
}

And the following css:以及以下 css:

.k-grid .k-grid-content tr.DisableRowSelection td:not(.k-hierarchy-cell) {
  opacity: 0.6;
  pointer-events: none;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM