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

Commit1d70c0c

Browse files
expose selectRowsByIndex and selectRowsByIds methods with table comp
1 parent16f4105 commit1d70c0c

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

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

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,76 @@ TableTmpComp = withMethodExposing(TableTmpComp, [
704704
comp.children.selection.children.selectedRowKey.dispatchChangeValueAction(allKeys[0]||"0");
705705
comp.children.selection.children.selectedRowKeys.dispatchChangeValueAction(allKeys);
706706
},
707-
},
707+
},
708+
{
709+
method:{
710+
name:"selectRowsByIndex",
711+
description:"Select rows by index",
712+
params:[
713+
{name:"rowIndexes",type:"arrayNumberString"},
714+
]
715+
},
716+
execute:(comp,values)=>{
717+
constrowIndexes=values[0];
718+
if(!isArray(rowIndexes)){
719+
returnPromise.reject("selectRowsByIndex function only accepts array of string or number i.e. ['1', '2', '3'] or [1, 2, 3]")
720+
}
721+
constdisplayData=comp.filterData??[];
722+
constselectedKeys:string[]=rowIndexes
723+
.map((index)=>{
724+
constnumIndex=Number(index);
725+
if(isNaN(numIndex)||numIndex<0||numIndex>=displayData.length){
726+
returnnull;
727+
}
728+
returndisplayData[numIndex][OB_ROW_ORI_INDEX];
729+
})
730+
.filter((key):key isstring=>key!==null);
731+
732+
comp.children.selection.children.selectedRowKey.dispatchChangeValueAction(selectedKeys[0]||"0");
733+
comp.children.selection.children.selectedRowKeys.dispatchChangeValueAction(selectedKeys);
734+
},
735+
},
736+
{
737+
method:{
738+
name:"selectRowsByIds",
739+
description:"Select rows by ids",
740+
params:[
741+
{name:"rowIds",type:"arrayNumberString"},
742+
]
743+
},
744+
execute:(comp,values)=>{
745+
constrowIds=values[0];
746+
if(!isArray(rowIds)){
747+
returnPromise.reject("selectRowsByIds function only accepts array of string or number i.e. ['1', '2', '3'] or [1, 2, 3]")
748+
}
749+
constdisplayData=comp.filterData??[];
750+
751+
// Common ID field names to check
752+
constidFields=['id','ID','Id','key','Key','KEY'];
753+
754+
constselectedKeys:string[]=rowIds
755+
.map((id)=>{
756+
// First try to find by common ID fields
757+
for(constfieldofidFields){
758+
constfoundRow=displayData.find((row)=>{
759+
constfieldValue=row[field];
760+
returnfieldValue!==undefined&&String(fieldValue)===String(id);
761+
});
762+
if(foundRow){
763+
returnfoundRow[OB_ROW_ORI_INDEX];
764+
}
765+
}
766+
767+
// If no ID field found, fall back to comparing with OB_ROW_ORI_INDEX
768+
constfoundRow=displayData.find((row)=>row[OB_ROW_ORI_INDEX]===String(id));
769+
returnfoundRow ?foundRow[OB_ROW_ORI_INDEX] :null;
770+
})
771+
.filter((key):key isstring=>key!==null);
772+
773+
comp.children.selection.children.selectedRowKey.dispatchChangeValueAction(selectedKeys[0]||"0");
774+
comp.children.selection.children.selectedRowKeys.dispatchChangeValueAction(selectedKeys);
775+
},
776+
},
708777
{
709778
method:{
710779
name:"cancelChanges",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp