Skip to content

Commit fc3325a

Browse files
Combine redundant Basic and Range Selection sections
- Merge Basic Cell Selection and Range Selection into single Cell Selection section - Rename Range Selection to Advanced Selection Event Handling for clarity - Rename Advanced Cell Selection Configuration to Advanced Configuration Options - Address GitHub comment feedback from Lendemor about section redundancy - Maintain all functionality while improving documentation structure Co-Authored-By: [email protected] <[email protected]>
1 parent 17c187b commit fc3325a

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

docs/enterprise/ag_grid/cell-selection.md

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@ from pcweb.pages.docs import enterprise
1111

1212
AG Grid provides powerful cell selection capabilities that allow users to select individual cells or ranges of cells. This feature is essential for data manipulation, copying, and advanced interactions like fill handle operations.
1313

14-
## Basic Cell Selection
14+
## Cell Selection
1515

16-
To enable cell selection in your AG Grid, set the `cell_selection` prop to `True`:
16+
To enable cell selection in your AG Grid, set the `cell_selection` prop to `True`. This automatically enables both single cell selection and range selection capabilities.
17+
18+
### Basic Selection Example
1719

1820
```python demo exec
1921
import reflex as rx
2022
import reflex_enterprise as rxe
2123
import pandas as pd
2224

23-
class BasicCellSelectionState(rx.State):
25+
class CellSelectionState(rx.State):
2426
data: list[dict] = []
2527

2628
@rx.event
@@ -50,27 +52,27 @@ def basic_cell_selection():
5052
rxe.ag_grid(
5153
id="basic_cell_selection_grid",
5254
column_defs=column_defs,
53-
row_data=BasicCellSelectionState.data,
55+
row_data=CellSelectionState.data,
5456
cell_selection=True,
55-
on_cell_selection_changed=BasicCellSelectionState.echo_selection,
57+
on_cell_selection_changed=CellSelectionState.echo_selection,
5658
width="100%",
5759
height="400px",
5860
),
59-
on_mount=BasicCellSelectionState.load_data,
61+
on_mount=CellSelectionState.load_data,
6062
width="100%",
6163
)
6264
```
6365

64-
## Range Selection
66+
### Advanced Selection Event Handling
6567

66-
Range selection is automatically enabled when you set `cell_selection=True`. This allows users to select multiple cells at once and perform operations across ranges.
68+
For more sophisticated selection handling, you can process the selection ranges to calculate detailed information:
6769

6870
```python demo exec
6971
import reflex as rx
7072
import reflex_enterprise as rxe
7173
import pandas as pd
7274

73-
class RangeSelectionState(rx.State):
75+
class AdvancedSelectionState(rx.State):
7476
data: list[dict] = []
7577

7678
@rx.event
@@ -100,19 +102,19 @@ editable_column_defs = [
100102
{"field": "attempts", "width": 120, "editable": True},
101103
]
102104

103-
def range_selection_example():
105+
def advanced_selection_example():
104106
return rx.vstack(
105107
rx.text("Select ranges of cells. Try selecting multiple ranges by holding Ctrl/Cmd.", size="2"),
106108
rxe.ag_grid(
107-
id="range_selection_grid",
109+
id="advanced_selection_grid",
108110
column_defs=editable_column_defs,
109-
row_data=RangeSelectionState.data,
111+
row_data=AdvancedSelectionState.data,
110112
cell_selection=True,
111-
on_cell_selection_changed=RangeSelectionState.handle_selection,
113+
on_cell_selection_changed=AdvancedSelectionState.handle_selection,
112114
width="100%",
113115
height="300px",
114116
),
115-
on_mount=RangeSelectionState.load_data,
117+
on_mount=AdvancedSelectionState.load_data,
116118
width="100%",
117119
)
118120
```
@@ -214,7 +216,7 @@ def fill_handle_example():
214216
)
215217
```
216218

217-
## Advanced Cell Selection Configuration
219+
## Advanced Configuration Options
218220

219221
You can further customize cell selection behavior using additional configuration options:
220222

@@ -223,7 +225,7 @@ import reflex as rx
223225
import reflex_enterprise as rxe
224226
import pandas as pd
225227

226-
class AdvancedSelectionState(rx.State):
228+
class ConfigurationState(rx.State):
227229
data: list[dict] = []
228230

229231
@rx.event
@@ -237,21 +239,21 @@ class AdvancedSelectionState(rx.State):
237239
})
238240
self.data = df.to_dict("records")
239241

240-
advanced_column_defs = [
242+
configuration_column_defs = [
241243
{"field": "id", "width": 80},
242244
{"field": "name", "width": 150, "editable": True},
243245
{"field": "category", "width": 120},
244246
{"field": "price", "width": 100, "editable": True, "type": "numericColumn"},
245247
{"field": "stock", "width": 100, "editable": True, "type": "numericColumn"},
246248
]
247249

248-
def advanced_selection_example():
250+
def configuration_example():
249251
return rx.vstack(
250-
rx.text("Advanced cell selection with custom configuration", size="2"),
252+
rx.text("Cell selection with additional configuration options", size="2"),
251253
rxe.ag_grid(
252-
id="advanced_selection_grid",
253-
column_defs=advanced_column_defs,
254-
row_data=AdvancedSelectionState.data,
254+
id="configuration_grid",
255+
column_defs=configuration_column_defs,
256+
row_data=ConfigurationState.data,
255257
cell_selection={
256258
"handle": {
257259
"mode": "fill",
@@ -262,22 +264,22 @@ def advanced_selection_example():
262264
width="100%",
263265
height="350px",
264266
),
265-
on_mount=AdvancedSelectionState.load_data,
267+
on_mount=ConfigurationState.load_data,
266268
width="100%",
267269
)
268270
```
269271

270272
## Key Features
271273

272-
- **Cell Selection**: Enable with `cell_selection=True` for basic cell selection and automatic range selection
274+
- **Cell Selection**: Enable with `cell_selection=True` for both single cell and range selection capabilities
273275
- **Fill Handle**: Configure with `cell_selection={"handle": {"mode": "fill"}}` for drag-to-fill functionality
274276
- **Event Handling**: Use `on_cell_selection_changed` to respond to selection changes
275277
- **Value Changes**: Use `on_cell_value_changed` to handle individual cell edits and fill operations
276278
- **Text Selection**: Enable `enable_cell_text_selection=True` to allow text selection within cells
277279

278280
## Best Practices
279281

280-
1. **Use cell_selection configuration**: Range selection is automatically enabled with `cell_selection=True` and provides all necessary selection capabilities for fill operations.
282+
1. **Use cell_selection configuration**: Both single cell and range selection are automatically enabled with `cell_selection=True`, providing all necessary selection capabilities for fill operations.
281283

282284
2. **Handle cell value changes**: When using fill handle, implement `on_cell_value_changed` to process the data updates in your backend.
283285

0 commit comments

Comments
 (0)