Skip to content

Commit 945c49a

Browse files
Table: expose both cell name and dataIndex for selected cell
1 parent 6c48539 commit 945c49a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

client/packages/lowcoder/src/comps/comps/tableComp/tableCompView.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ type CustomTableProps<RecordType> = Omit<TableProps<RecordType>, "components" |
477477
columnsStyle: TableColumnStyleType;
478478
size?: string;
479479
rowAutoHeight?: boolean;
480-
onCellClick: (columnName: string) => void;
480+
onCellClick: (columnName: string, dataIndex: string) => void;
481481
};
482482

483483
function TableCellView(props: {
@@ -632,7 +632,9 @@ function ResizeableTable<RecordType extends object>(props: CustomTableProps<Reco
632632
linkStyle,
633633
tableSize: props.size,
634634
autoHeight: props.rowAutoHeight,
635-
onClick: () => props.onCellClick(col.titleText),
635+
onClick: () => {
636+
props.onCellClick(col.titleText, String(col.dataIndex));
637+
}
636638
}),
637639
onHeaderCell: () => ({
638640
width: resizeWidth,
@@ -870,8 +872,11 @@ export function TableCompView(props: {
870872
(compChildren.data as any).isLoading()) ||
871873
compChildren.loading.getView()
872874
}
873-
onCellClick={(columnName: string) => {
874-
comp.children.selectedCell.dispatchChangeValueAction(columnName);
875+
onCellClick={(columnName: string, dataIndex: string) => {
876+
comp.children.selectedCell.dispatchChangeValueAction({
877+
name: columnName,
878+
dataIndex: dataIndex,
879+
});
875880
}}
876881
/>
877882

client/packages/lowcoder/src/comps/comps/tableComp/tableTypes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ const tableChildrenMap = {
225225
// todo: support object config
226226
dynamicColumnConfig: ArrayStringControl,
227227
expansion: ExpansionControl,
228-
selectedCell: stateComp<string>(''),
228+
selectedCell: stateComp<JSONObject>({}),
229229
};
230230

231231
export const TableInitComp = (function () {

0 commit comments

Comments
 (0)