简体   繁体   中英

Select all works to unselect some but not to select or clear all

I created a kendo grid with multiselect enabled:

    <kendo-grid
      [reorderable]="false"
      class="border"
      [kendoGridBinding]="data"
      [selectable]="{ enabled: true, checkboxOnly: false, mode: 'multiple' }"
      scrollable="none"
    >
      <kendo-grid-checkbox-column
        [showSelectAll]="true"
        [width]="40"
        [columnMenu]="false"
        headerClass="col-header"
      ></kendo-grid-checkbox-column>
      <kendo-grid-column
        title="Person Name"
        headerClass="font-weight-bold col-header"
      >
        <ng-template kendoGridCellTemplate let-dataItem>
          {{ dataItem.lastName }}, {{ dataItem.firstName }}
        </ng-template>
      </kendo-grid-column>

I'm using showSelectAll on the kendo-grid-checkbox-column in order to enable selection of all of the grid rows via a checkbox in the header. I've seen this work in the Kendo for Angular demos in the documentation.

For me, clicking the header checkbox does nothing when nothing is selected:

未选择任何内容,标题复选框不起作用

When I select a row manually, clicking the header checkbox when it shows a '-' sign unselects selected rows:

选择了一些行,标题复选框有效

When I select all of the rows manually (shift clicking them works), clicking the header checkbox with a check mark in it also doesn't work:

选中所有行,标题复选框不起作用

So it doesn't work for selecting all or unselecting all, but works for unselecting some.

Any ideas what I'm doing wrong and what I should try to get this to work?

Thanks!

It's really hard to tell what might be causing the problem based on the provided information - I just created a StackBlitz demo with the latest official versions of the Kendo packages, and the provided markup, and it seems to be working as expected:

https://stackblitz.com/edit/angular-gmiahh?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.module.ts

You can compare this to the actual implementation and apply the necessary adjustments.

EDIT: If the Grid happens to be used alongside Angular Material CDK Overlay, you can also check out this article:

https://www.telerik.com/kendo-angular-ui/components/knowledge-base/selectall-ngmaterialcdk/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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