Skip to content

Commit b1a3d81

Browse files
feat: add selection column width property to DataGrid (#1034)
1 parent 6e71e9b commit b1a3d81

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

.changeset/gorgeous-apes-sing.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@ensembleui/react-kitchen-sink": patch
3+
"@ensembleui/react-runtime": patch
4+
---
5+
6+
feat: add selection column width property to DataGrid

apps/kitchen-sink/src/ensemble/screens/widgets.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ View:
290290
executeCode: |
291291
console.log("data", selectedRows, selectedRowKeys);
292292
allowSelection: ${1===1}
293+
selectionColWidth: ${20+30}
293294
selectionType: '${1===10 ? "checkbox" : "radio"}'
294295
allowResizableColumns: true
295296
defaultSelectedRowKeys: ["2"]

packages/runtime/src/widgets/DataGrid/DataGrid.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export interface DataGridScrollable {
9191
export type GridProps = {
9292
allowSelection?: boolean;
9393
selectionType?: "checkbox" | "radio";
94+
selectionColWidth?: number;
9495
allowResizableColumns?: boolean;
9596
onRowsSelected?: EnsembleAction;
9697
defaultSelectedRowKeys?: string[];
@@ -178,6 +179,7 @@ export const DataGrid: React.FC<GridProps> = (props) => {
178179
const [selectionType, setSelectionType] = useState<"checkbox" | "radio">(
179180
props.selectionType ? props.selectionType : "checkbox",
180181
);
182+
const selectionColWidth = props.selectionColWidth || 50;
181183
const containerRef = useRef<HTMLDivElement>(null);
182184
const { namedData } = useTemplateData({ ...itemTemplate });
183185
const components = {
@@ -314,6 +316,7 @@ export const DataGrid: React.FC<GridProps> = (props) => {
314316
rowsSelected,
315317
selectionType,
316318
allowSelection,
319+
selectionColWidth,
317320
pageSize,
318321
curPage,
319322
widgetName,
@@ -474,6 +477,7 @@ export const DataGrid: React.FC<GridProps> = (props) => {
474477
rowSelection={
475478
allowSelection
476479
? {
480+
columnWidth: values?.selectionColWidth,
477481
type: selectionType,
478482
onChange: (selectedRowKeys, selectedRows): void => {
479483
setRowsKey(selectedRowKeys);

0 commit comments

Comments
 (0)