Determine selection when using OnRead

1 Answer 185 Views
Grid
Thomas
Top achievements
Rank 1
Thomas asked on 17 Jun 2022, 10:15 AM

Hello

 

For a recent project I have to display around 100 000 rows in a grid, I have to be able to sort/filter and select certain rows/select all rows in a filter.
Because it's quite a lot of data I've decided to use the OnRead event on the TelerikGrid, this all seems to work fine except for the ability to select all rows (only the rows on the current page are selected). The grid looks something like this: 

The code looks something like this:

<TelerikGrid AutoGenerateColumns=true
             OnRead="@ReadItems"
             TItem=ProductDto
             Pageable=true
             PageSize=10
             Sortable
             SelectionMode=@GridSelectionMode.Multiple
             FilterMenuType=@FilterMenuType.Menu
             FilterMode="GridFilterMode.FilterMenu"
             Resizable="true"
             ScrollMode="@GridScrollMode.Scrollable"
             SelectedItemsChanged="@((IEnumerable<ProductDto> newSelection) => onSelect(newSelection))"
             Reorderable="true"
             SelectedItems="@selectedProducts"
             >
    <GridColumns>
        <GridCheckboxColumn  CheckBoxOnlySelection="true" Reorderable=false SelectAllMode=@GridSelectAllMode.All Width="100px" SelectAll="true" Locked="true" />
        <GridColumn Field="@nameof(ProductDto.Id)" Title="@_localizer[nameof(Translations.Id)]" Width="100px" Locked="true" />
        <GridColumn Field="@nameof(ProductDto.Code)" Title="@_localizer[nameof(Translations.Code)]" Width="200px" Locked="true" />
        <GridColumn Field="@nameof(ProductDto.ExternalReference)" Title="@_localizer[nameof(Translations.ExternalReference)]" Width="200px" Locked="true" Lockable="true" />
        <GridColumn Field="@nameof(ProductDto.Description)" Title="@_localizer[nameof(Translations.Description)]" Width="200px" Lockable="true" />
        <GridColumn Field="@nameof(ProductDto.BrandCode)" Title="@_localizer[nameof(Translations.BrandCode)]" Width="200px" Lockable="true" />
        <GridAutoGeneratedColumns ColumnWidth="200px" />
    </GridColumns>
</TelerikGrid>

Since I use the OnRead event, only a small amount of data is available client side, when I click the header checkbox of the GridCheckboxColumn all the items that are available client-side get selected BUT, I would like to be able to tell whether a user clicked the checkbox in the header (=select everything in the grid), or if the user just manually selected all the visible rows of a certain page.

TLDR: How to determine whether a user clicked the header checkbox (= select everything) vs a user manually clicked all items on a certain page. (The selectedItems result is both the same)

Kind regards

Thomas

 

1 Answer, 1 is accepted

Sort by
1
Accepted
Dimo
Telerik team
answered on 22 Jun 2022, 08:29 AM

Hi Thomas,

It will be possible to distinguish "select all" clicks when we release UI for Blazor 3.4.0 later today. The new version will expose a HeaderTemplate for the GridCheckBoxColumn.

There will be a new "CheckBox Column" article in the Grid Columns folder with more information.

Regards,
Dimo
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Thomas
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or