Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9a1295e

Browse files
added currentExpandedRow, currentExpandedRows and setExpandedRows in table comp
1 parent6cf8dc0 commit9a1295e

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,24 @@ TableTmpComp = withMethodExposing(TableTmpComp, [
724724
comp.children.columns.dispatchClearInsertSet();
725725
},
726726
},
727+
{
728+
method:{
729+
name:"setExpandedRows",
730+
description:"",
731+
params:[
732+
{name:"expandedRows",type:"arrayString"},
733+
],
734+
},
735+
execute:(comp,values)=>{
736+
constexpandedRows=values[0];
737+
if(!isArray(expandedRows)){
738+
returnPromise.reject("setExpandedRows function only accepts array of string i.e. ['1', '2', '3']")
739+
}
740+
if(expandedRows&&isArray(expandedRows)){
741+
comp.children.currentExpandedRows.dispatchChangeValueAction(expandedRowsasstring[]);
742+
}
743+
},
744+
}
727745
]);
728746

729747
// exposing data
@@ -978,5 +996,24 @@ export const TableComp = withExposingConfigs(TableTmpComp, [
978996
},
979997
trans("table.selectedCellDesc")
980998
),
999+
depsConfig({
1000+
name:"currentExpandedRow",
1001+
desc:trans("table.sortDesc"),
1002+
depKeys:["currentExpandedRows"],
1003+
func:(input)=>{
1004+
if(input.currentExpandedRows.length>0){
1005+
returninput.currentExpandedRows[input.currentExpandedRows.length-1];
1006+
}
1007+
return"";
1008+
},
1009+
}),
1010+
depsConfig({
1011+
name:"currentExpandedRows",
1012+
desc:trans("table.sortDesc"),
1013+
depKeys:["currentExpandedRows"],
1014+
func:(input)=>{
1015+
returninput.currentExpandedRows;
1016+
},
1017+
}),
9811018
newNameConfig("data",trans("table.dataDesc")),
9821019
]);

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { CompNameContext, EditorContext } from "comps/editorState";
2828
import{BackgroundColorContext}from"comps/utils/backgroundColorContext";
2929
import{PrimaryColor}from"constants/style";
3030
import{trans}from"i18n";
31-
import_from"lodash";
31+
import_,{isEqual}from"lodash";
3232
import{darkenColor,isDarkColor,isValidColor,ScrollBar}from"lowcoder-design";
3333
importReact,{Children,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";
3434
import{Resizable}from"react-resizable";
@@ -48,6 +48,7 @@ import { TableSummary } from "./tableSummaryComp";
4848
importSkeletonfrom"antd/es/skeleton";
4949
import{SkeletonButtonProps}from"antd/es/skeleton/Button";
5050
import{ThemeContext}from"@lowcoder-ee/comps/utils/themeContext";
51+
import{useUpdateEffect}from"react-use";
5152

5253
exportconstEMPTY_ROW_KEY='empty_row';
5354

@@ -814,6 +815,7 @@ export const TableCompView = React.memo((props: {
814815
onRefresh:(allQueryNames:Array<string>,setLoading:(loading:boolean)=>void)=>void;
815816
onDownload:(fileName:string)=>void;
816817
})=>{
818+
const[expandedRowKeys,setExpandedRowKeys]=useState<string[]>([]);
817819
const[emptyRowsMap,setEmptyRowsMap]=useState<Record<string,RecordType>>({});
818820
consteditorState=useContext(EditorContext);
819821
constcurrentTheme=useContext(ThemeContext)?.theme;
@@ -856,6 +858,7 @@ export const TableCompView = React.memo((props: {
856858
constsize=useMemo(()=>compChildren.size.getView(),[compChildren.size]);
857859
consteditModeClicks=useMemo(()=>compChildren.editModeClicks.getView(),[compChildren.editModeClicks]);
858860
constonEvent=useMemo(()=>compChildren.onEvent.getView(),[compChildren.onEvent]);
861+
constcurrentExpandedRows=useMemo(()=>compChildren.currentExpandedRows.getView(),[compChildren.currentExpandedRows]);
859862
constdynamicColumn=compChildren.dynamicColumn.getView();
860863
constdynamicColumnConfig=useMemo(
861864
()=>compChildren.dynamicColumnConfig.getView(),
@@ -955,6 +958,18 @@ export const TableCompView = React.memo((props: {
955958
updateEmptyRows();
956959
},[updateEmptyRows]);
957960

961+
useUpdateEffect(()=>{
962+
if(!isEqual(currentExpandedRows,expandedRowKeys)){
963+
compChildren.currentExpandedRows.dispatchChangeValueAction(expandedRowKeys);
964+
}
965+
},[expandedRowKeys]);
966+
967+
useUpdateEffect(()=>{
968+
if(!isEqual(currentExpandedRows,expandedRowKeys)){
969+
setExpandedRowKeys(currentExpandedRows);
970+
}
971+
},[currentExpandedRows]);
972+
958973
constpageDataInfo=useMemo(()=>{
959974
// Data pagination
960975
letpagedData=data;
@@ -1104,7 +1119,11 @@ export const TableCompView = React.memo((props: {
11041119
}else{
11051120
handleChangeEvent('rowShrink')
11061121
}
1107-
}
1122+
},
1123+
onExpandedRowsChange:(expandedRowKeys)=>{
1124+
setExpandedRowKeys(expandedRowKeysasunknownasstring[]);
1125+
},
1126+
expandedRowKeys:expandedRowKeys,
11081127
}}
11091128
// rowKey={OB_ROW_ORI_INDEX}
11101129
rowColorFn={compChildren.rowColor.getView()asany}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ const tableChildrenMap = {
265265
selectedCell:stateComp<JSONObject>({}),
266266
inlineAddNewRow:BoolControl,
267267
editModeClicks:dropdownControl(editModeClickOptions,"single"),
268+
currentExpandedRows:stateComp<string[]>([]),
268269
};
269270

270271
exportconstTableInitComp=(function(){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp