Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(Grid): add kb for selectall with onRead #2697

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ntacheva
Copy link
Contributor

No description provided.

@ntacheva ntacheva added the merge-to-production Use this label to get a comment to choose whether to merge the PR to production label Jan 10, 2025
@ntacheva ntacheva self-assigned this Jan 10, 2025
@ntacheva ntacheva requested a review from a team as a code owner January 10, 2025 16:55
Copy link
Contributor

Hello @ntacheva,

Check the below option if you would like to automatically generate PR to production. The automation uses the branch for the cherry-pick, and then will delete the branch. Please, do not delete it manually.

  • create PR to production


## Solution

The described behavior is expected as when using the `OnRead` event, the Grid operates only with the current set/page of data. The component does not have information for all the items in your datasource and [thus it cannot select them all](slug:grid-selection-row#selection-and-paging).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph belongs to a Cause section.


1. Use [`HeaderTemplate` for the `CheckboxColumn`](slug:components/grid/columns/checkbox#header-template) and add a custom [CheckBox component](slug:checkbox-overview) so you can have full control over its behavior.
1. Handle the [`OnChange` event](slug:checkbox-events#onchange) of the CheckBox to track when the user checks/unchecks it to manage the selected items.
- When the CheckBox is checked, request all the data from your datasource and assign it to the `SelectedItems` collection, so you have all items selected. You may want to cache all the data for further usage, so you don't need to request it additionally upon clicking the custom SelectAll CheckBox.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may not be acceptable if the data item count is too large. Another option is to raise a flag, so that all new items received in OnRead (e.g. during paging) are added to SelectedItems.

private List<Employee> GenerateData()
{
var result = new List<Employee>();
var rand = new Random();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the static Random.Shared instead.

@@ -0,0 +1,147 @@
---
title: Select All Items With CheckBox when Using OnRead
Copy link
Contributor

@dimodi dimodi Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SEO

Suggested change
title: Select All Items With CheckBox when Using OnRead
title: Select All Grid Items With CheckBox when Using OnRead

@@ -0,0 +1,147 @@
---
title: Select All Items With CheckBox when Using OnRead
description: How Select All Items With CheckBox when Using OnRead in the Grid for Blazor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: How Select All Items With CheckBox when Using OnRead in the Grid for Blazor
description: How to select all Grid rows with checkBox when using the OnRead event in the Telerik Grid for Blazor.

title: Select All Items With CheckBox when Using OnRead
description: How Select All Items With CheckBox when Using OnRead in the Grid for Blazor
type: how-to
page_title: How Select All Items With CheckBox when Using OnRead
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
page_title: How Select All Items With CheckBox when Using OnRead
page_title: How to Select All Grid Items With CheckBox when Using OnRead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-to-production Use this label to get a comment to choose whether to merge the PR to production
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants