File tree Expand file tree Collapse file tree 2 files changed +43
-2
lines changed
static/app/views/dashboards/widgets/tableWidget Expand file tree Collapse file tree 2 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -405,6 +405,16 @@ function getRenderer(fieldName: string) {
405
405
used as a loading placeholder
406
406
</ p >
407
407
< TableWidgetVisualization . LoadingPlaceholder />
408
+ < p >
409
+ Optionally, you can pass the
410
+ < code > columns</ code >
411
+ prop to render them in the loading placeholder. You can also pass
412
+ < code > aliases</ code > to apply custom names to columns. Note: sorting and
413
+ resizing are disabled in the loading placeholder.
414
+ </ p >
415
+ < TableWidgetVisualization . LoadingPlaceholder
416
+ columns = { customColumns . map ( column => ( { ...column , width : - 1 } ) ) }
417
+ />
408
418
</ Fragment >
409
419
) ;
410
420
} ) ;
Original file line number Diff line number Diff line change @@ -280,9 +280,40 @@ export function TableWidgetVisualization(props: TableWidgetVisualizationProps) {
280
280
) ;
281
281
}
282
282
283
- TableWidgetVisualization . LoadingPlaceholder = function ( ) {
283
+ TableWidgetVisualization . LoadingPlaceholder = function ( {
284
+ columns,
285
+ aliases,
286
+ } : {
287
+ aliases ?: Record < string , string > ;
288
+ columns ?: TabularColumn [ ] ;
289
+ } ) {
290
+ const columnsWithName = columns ?. map ( column => ( { ...column , name : column . key } ) ) ?? [ ] ;
284
291
return (
285
- < GridEditable isLoading columnOrder = { [ ] } columnSortBy = { [ ] } data = { [ ] } grid = { { } } />
292
+ < GridEditable
293
+ isLoading
294
+ columnOrder = { columnsWithName }
295
+ columnSortBy = { [ ] }
296
+ data = { [ ] }
297
+ resizable = { false }
298
+ grid = { {
299
+ renderHeadCell : ( _tableColumn , columnIndex ) => {
300
+ if ( ! columns ) return null ;
301
+ const column = columns [ columnIndex ] ! ;
302
+ const align = fieldAlignment ( column . key , column . type as ColumnValueType ) ;
303
+ const name = aliases ?. [ column . key ] || column . key ;
304
+
305
+ return (
306
+ < SortLink
307
+ canSort = { false }
308
+ align = { align }
309
+ title = { < StyledTooltip title = { name } > { name } </ StyledTooltip > }
310
+ direction = { undefined }
311
+ generateSortLink = { ( ) => undefined }
312
+ />
313
+ ) ;
314
+ } ,
315
+ } }
316
+ />
286
317
) ;
287
318
} ;
288
319
You can’t perform that action at this time.
0 commit comments