File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed
packages/drip-table-generator/src
layouts/table-workstation/editable-table/components Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ ExtraOptions extends Partial<DripTableExtraOptions> = never,
108108 columns : newColumns ,
109109 currentTableID : props . tableConfig . tableId ,
110110 tableConfig : props . tableConfig ,
111+ columnIndex : index ,
111112 } ) ;
112113 return newColumns ;
113114 } }
@@ -135,6 +136,7 @@ ExtraOptions extends Partial<DripTableExtraOptions> = never,
135136 columns : newColumns ,
136137 currentTableID : props . tableConfig . tableId ,
137138 tableConfig : props . tableConfig ,
139+ columnIndex : index ,
138140 } ) ;
139141 return newColumns ;
140142 } }
Original file line number Diff line number Diff line change @@ -203,15 +203,19 @@ ExtraOptions extends Partial<DripTableExtraOptions> = never,
203203 } else {
204204 const lastSortableColumnIndex = tableConfigs [ tableIndex ] . columns . map ( item => ! ! item . fixed ) . lastIndexOf ( false ) ;
205205 let columns = [ ...tableConfigs [ tableIndex ] . columns ] ;
206+ let columnIndex = columns . length - 1 ;
206207 if ( props . customColumns ) {
207208 columns = props . customColumns ( tableConfigs [ tableIndex ] . columns , column ) ;
209+ columnIndex = columns . findIndex ( item => item . key === column . key ) ;
208210 } else if ( lastSortableColumnIndex < columns . length - 1 ) {
209211 columns . splice ( lastSortableColumnIndex + 1 , 0 , column ) ;
212+ columnIndex = lastSortableColumnIndex + 1 ;
210213 } else {
211214 columns = [ ...tableConfigs [ tableIndex ] . columns , column ] ;
215+ columnIndex += 1 ;
212216 }
213217 setTableColumns ( columns , tableIndex , ( configs ) => {
214- props . onColumnAdded ?.( column , getSchemaValue ( configs ) ) ;
218+ props . onColumnAdded ?.( column , getSchemaValue ( configs ) , columnIndex ) ;
215219 } ) ;
216220 }
217221 initStates ( ) ;
Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ export interface DripTableGeneratorProps<
277277 onExportSchema ?: ( schema : DripTableSchema < DripTableColumnSchema > ) => void ;
278278 onSchemaChange ?: ( schema : DripTableSchema < DripTableColumnSchema > ) => void ;
279279 onDataSourceChange ?: ( dataSource : DripTableProps < RecordType , ExtraOptions > [ 'dataSource' ] ) => void ;
280- onColumnAdded ?: ( column : DripTableSchema < DripTableColumnSchema > [ 'columns' ] [ number ] , schema : DripTableSchema < DripTableColumnSchema > ) => void ;
280+ onColumnAdded ?: ( column : DripTableSchema < DripTableColumnSchema > [ 'columns' ] [ number ] , schema : DripTableSchema < DripTableColumnSchema > , columnIndex : number ) => void ;
281281 onClose ?: ( schema ?: DripTableSchema < DripTableColumnSchema > ) => void ;
282282 onSave ?: ( schema : DripTableSchema < DripTableColumnSchema > ) => void ;
283283 /**
You can’t perform that action at this time.
0 commit comments