@@ -704,7 +704,76 @@ TableTmpComp = withMethodExposing(TableTmpComp, [
704704comp . children . selection . children . selectedRowKey . dispatchChangeValueAction ( allKeys [ 0 ] || "0" ) ;
705705comp . 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+ const rowIndexes = values [ 0 ] ;
718+ if ( ! isArray ( rowIndexes ) ) {
719+ return Promise . reject ( "selectRowsByIndex function only accepts array of string or number i.e. ['1', '2', '3'] or [1, 2, 3]" )
720+ }
721+ const displayData = comp . filterData ?? [ ] ;
722+ const selectedKeys :string [ ] = rowIndexes
723+ . map ( ( index ) => {
724+ const numIndex = Number ( index ) ;
725+ if ( isNaN ( numIndex ) || numIndex < 0 || numIndex >= displayData . length ) {
726+ return null ;
727+ }
728+ return displayData [ 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+ const rowIds = values [ 0 ] ;
746+ if ( ! isArray ( rowIds ) ) {
747+ return Promise . reject ( "selectRowsByIds function only accepts array of string or number i.e. ['1', '2', '3'] or [1, 2, 3]" )
748+ }
749+ const displayData = comp . filterData ?? [ ] ;
750+
751+ // Common ID field names to check
752+ const idFields = [ 'id' , 'ID' , 'Id' , 'key' , 'Key' , 'KEY' ] ;
753+
754+ const selectedKeys :string [ ] = rowIds
755+ . map ( ( id ) => {
756+ // First try to find by common ID fields
757+ for ( const field of idFields ) {
758+ const foundRow = displayData . find ( ( row ) => {
759+ const fieldValue = row [ field ] ;
760+ return fieldValue !== undefined && String ( fieldValue ) === String ( id ) ;
761+ } ) ;
762+ if ( foundRow ) {
763+ return foundRow [ OB_ROW_ORI_INDEX ] ;
764+ }
765+ }
766+
767+ // If no ID field found, fall back to comparing with OB_ROW_ORI_INDEX
768+ const foundRow = displayData . find ( ( row ) => row [ OB_ROW_ORI_INDEX ] === String ( id ) ) ;
769+ return foundRow ?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{
709778method :{
710779name :"cancelChanges" ,