Skip to content

Commit 4b9604b

Browse files
committed
Add blog post about disabled rows
1 parent e693c98 commit 4b9604b

1 file changed

Lines changed: 148 additions & 0 deletions

File tree

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
---
2+
title: Disable rows in your React DataGrid without losing context
3+
description: Use Infinite Table disabled rows to keep records visible while removing them from selection, clicks, and keyboard navigation.
4+
date: 2026-07-16
5+
author: radu
6+
tags: rows, datasource, keyboard-navigation
7+
---
8+
9+
Sometimes a row should stay visible even when users should not interact with it.
10+
11+
Think of archived invoices, locked workflow steps, read-only audit entries, expired offers, or records a user can see but cannot act on. Filtering those rows away hides important context. Styling them only as muted still leaves them selectable, clickable, and reachable with the keyboard.
12+
13+
Infinite Table's [disabled rows docs](/docs/learn/rows/disabled-rows) cover the feature in detail. This article focuses on the practical pattern: let the `DataSource` own which rows are disabled, and let the grid automatically respect that state across row selection, pointer interaction, and keyboard navigation.
14+
15+
## Disabled rows are a data state
16+
17+
Disabled rows are configured on `<DataSource />`, not as one-off CSS on `<InfiniteTable />`. That matters because the disabled state affects interaction, not just rendering.
18+
19+
The uncontrolled version uses <DataSourcePropLink name="defaultRowDisabledState" />.
20+
21+
```tsx
22+
<DataSource<Developer>
23+
primaryKey="id"
24+
data={data}
25+
defaultRowDisabledState={{
26+
enabledRows: true,
27+
disabledRows: [1, 3, 4, 5],
28+
}}
29+
>
30+
<InfiniteTable<Developer>
31+
columns={columns}
32+
keyboardNavigation="row"
33+
/>
34+
</DataSource>
35+
```
36+
37+
This means every row is enabled by default except the rows with ids `1`, `3`, `4`, and `5`.
38+
39+
You can also flip the model when the blocked state is the common case:
40+
41+
```tsx
42+
defaultRowDisabledState={{
43+
enabledRows: [1, 2, 3, 5],
44+
disabledRows: true,
45+
}}
46+
```
47+
48+
That shape is useful for permission-driven screens where most records are locked and only a smaller allow-list should stay interactive.
49+
50+
## See initial disabled rows in action
51+
52+
The docs example below starts with a few disabled rows and enables row keyboard navigation so the difference is easy to test.
53+
54+
<Sandpack title="Initial disabled row state" size="md" viewMode="preview">
55+
56+
<Description>
57+
58+
Click the grid and navigate with the keyboard. Disabled rows remain visible, but they are skipped by row navigation and interaction.
59+
60+
</Description>
61+
62+
```tsx live file="$DOCS/learn/rows/initialRowDisabledState-example.page.tsx"
63+
64+
```
65+
66+
</Sandpack>
67+
68+
## Render the disabled state where it helps users
69+
70+
Once the `DataSource` knows which rows are disabled, your cell renderers can read that state from `rowInfo.rowDisabled`.
71+
72+
```tsx
73+
const columns: InfiniteTablePropColumns<Developer> = {
74+
firstName: {
75+
field: 'firstName',
76+
renderValue: ({ rowInfo, value }) => {
77+
return `${value} ${rowInfo.rowDisabled ? 'disabled' : ''}`;
78+
},
79+
},
80+
};
81+
```
82+
83+
That gives you one source of truth for both behavior and presentation. You can dim a row, add a label, show a lock icon, or change the available row actions without duplicating permission logic in every component.
84+
85+
<Sandpack title="Render disabled rows differently" size="md" viewMode="preview">
86+
87+
<Description>
88+
89+
This example uses `rowInfo.rowDisabled` while rendering the `firstName` column, and includes buttons for enabling or disabling all rows.
90+
91+
</Description>
92+
93+
```tsx live file="$DOCS/learn/rows/custom-rendering-for-disabled-rows-example.page.tsx"
94+
95+
```
96+
97+
</Sandpack>
98+
99+
## Change row availability at runtime
100+
101+
Disabled state often changes after the grid is mounted. A review queue can unlock a record. A batch operation can mark records as unavailable. A context menu can give admins a quick toggle.
102+
103+
Use the <DApiLink name="setRowEnabled" /> and <DApiLink name="setRowEnabledAt" /> methods from the `DataSource` API for those cases.
104+
105+
```tsx
106+
dataSourceApi.setRowEnabled(rowId, true);
107+
dataSourceApi.setRowEnabledAt(rowIndex, false);
108+
```
109+
110+
The id-based version is usually the clearest option when you are responding to app data. The index-based version is useful when the action comes from the current rendered row position.
111+
112+
The docs example below wires this into a row context menu:
113+
114+
<Sandpack title="Toggle disabled rows with the DataSource API" size="md" viewMode="preview">
115+
116+
<Description>
117+
118+
Right-click a row to open the context menu, then enable, disable, or toggle that row. The menu actions call the DataSource API.
119+
120+
</Description>
121+
122+
```tsx live file="$DOCS/learn/rows/using-api-to-disable-rows-example.page.tsx"
123+
124+
```
125+
126+
</Sandpack>
127+
128+
## When this is better than filtering
129+
130+
Reach for disabled rows when users still need to understand why a record is present, but should not be able to act on it.
131+
132+
Good examples include:
133+
134+
- rows locked by permissions
135+
- archived or expired records kept for reference
136+
- rows already included in another workflow step
137+
- pending records waiting for validation
138+
- inventory items temporarily unavailable for selection
139+
140+
Filtering is still the right tool when the row should disappear from the current view. Disabled rows are better when the row is part of the story, but not part of the action.
141+
142+
## Go deeper in the docs
143+
144+
Start with the [disabled rows guide](/docs/learn/rows/disabled-rows) for the complete setup.
145+
146+
If the disabled state is derived from your own rules, check <DataSourcePropLink name="isRowDisabled" />. It lets you calculate row availability from the row data and can override the configured disabled-row state.
147+
148+
For runtime changes, use the [DataSource API reference](/docs/reference/datasource-api) alongside the disabled rows examples.

0 commit comments

Comments
 (0)