Skip to content

Commit 93504a8

Browse files
committed
AI Assistant: Use selectAll/deselectAll commands taking into account selectAllMode option
1 parent 92490a7 commit 93504a8

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

  • packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands

packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/selection.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ export const selectionByIndexesCommand = defineGridCommand({
185185
+ 'Always set scope to choose how indexes are interpreted: '
186186
+ '"allPages" — indexes are positions within the currently filtered and sorted dataset, NOT limited to the current page; index 1 is the first row of the dataset, regardless of pageIndex/pageSize. Use this when the user does NOT explicitly refer to the visible page (e.g. "select rows 1 to 100"). '
187187
+ '"page" — indexes are positions within the currently rendered page; index 1 is the first data row on the visible page and group/header rows are not counted. Use this ONLY when the user explicitly mentions the current/visible page (e.g. "select the first 3 rows on the current page", "deselect row 2 on this page"). '
188+
+ 'This ALSO covers "select/deselect ALL rows on the current/visible page" when selection.selectAllMode is "allPages" (in that case selectAll/deselectAll cannot target a single page, so use this command instead): list every 1-based index on the current page. The page holds up to pageSize rows and the last page may hold fewer, so use the paging context (pageIndex, pageSize, totalCount) to determine the exact count. '
188189
+ 'Set mode to "select" to add the listed rows to the current selection (multiple calls accumulate, so previously selected ranges are kept); set mode to "deselect" to remove the listed rows from the current selection (e.g. "unselect row 1"). '
189190
+ 'To clear selection only within the current selectAll scope, use deselectAll; to clear selection across all pages regardless of selectAllMode, use clearSelection. '
190191
+ 'To target rows by key value rather than by index, use selectByKeys.',
@@ -223,7 +224,9 @@ export const selectionByIndexesCommand = defineGridCommand({
223224

224225
export const selectAllCommand = defineGridCommand({
225226
name: 'selectAll',
226-
description: 'Select rows. Scope depends on selection.selectAllMode: "allPages" (default) selects across every page; "page" selects only the currently rendered page. If a filter is applied, only rows matching the filter are selected.',
227+
description: 'Select rows. Scope depends on selection.selectAllMode: "allPages" (default) selects across every page; "page" selects only the currently rendered page. If a filter is applied, only rows matching the filter are selected. '
228+
+ 'Use this command ONLY when the scope the user asks for matches selection.selectAllMode: for an unqualified "select all rows" request when selectAllMode is "allPages", or for "select all rows on the current/visible page" when selectAllMode is "page". '
229+
+ 'If the user asks to select all rows on the CURRENT/VISIBLE page but selectAllMode is "allPages", do NOT use this command (it would select every page) — instead use selectionByIndexes with scope "page", mode "select", and indexes listing every row on the current page.',
227230
schema: z.object({}).strict(),
228231
execute: (component, { success, failure }) => async (): Promise<CommandResult> => {
229232
const defaultMessage = 'Select all rows.';
@@ -244,7 +247,10 @@ export const selectAllCommand = defineGridCommand({
244247

245248
export const deselectAllCommand = defineGridCommand({
246249
name: 'deselectAll',
247-
description: 'Deselect rows. Scope depends on selection.selectAllMode: "allPages" (default) deselects across every page; "page" deselects only the currently rendered page. If a filter is applied, only rows matching the filter are deselected.',
250+
description: 'Deselect rows. Scope depends on selection.selectAllMode: "allPages" (default) deselects across every page; "page" deselects only the currently rendered page. If a filter is applied, only rows matching the filter are deselected. '
251+
+ 'Use this command ONLY when the scope the user asks for matches selection.selectAllMode: for an unqualified "deselect all rows" request when selectAllMode is "allPages", or for "deselect all rows on the current/visible page" when selectAllMode is "page". '
252+
+ 'If the user asks to deselect all rows on the CURRENT/VISIBLE page but selectAllMode is "allPages", do NOT use this command (it would deselect every page) — instead use selectionByIndexes with scope "page", mode "deselect", and indexes listing every row on the current page. '
253+
+ 'To clear selection across all pages regardless of selectAllMode, use clearSelection.',
248254
schema: z.object({}).strict(),
249255
execute: (component, { success, failure }) => async (): Promise<CommandResult> => {
250256
const defaultMessage = 'Deselect all rows.';

0 commit comments

Comments
 (0)