@@ -10,7 +10,12 @@ import '@ui5/webcomponents-icons/dist/delete';
10
10
import ' @ui5/webcomponents-icons/dist/edit' ;
11
11
import ' @ui5/webcomponents-icons/dist/settings' ;
12
12
import { Button } from ' @ui5/webcomponents-react/lib/Button' ;
13
+ import { Badge } from ' @ui5/webcomponents-react/lib/Badge' ;
14
+ import { Text } from ' @ui5/webcomponents-react/lib/Text' ;
13
15
import { FlexBox } from ' @ui5/webcomponents-react/lib/FlexBox' ;
16
+ import { FlexBoxAlignItems } from ' @ui5/webcomponents-react/lib/FlexBoxAlignItems' ;
17
+ import { FlexBoxDirection } from ' @ui5/webcomponents-react/lib/FlexBoxDirection' ;
18
+ import { FlexBoxJustifyContent } from ' @ui5/webcomponents-react/lib/FlexBoxJustifyContent' ;
14
19
import { TextAlign } from ' @ui5/webcomponents-react/lib/TextAlign' ;
15
20
import { DefaultLoadingComponent } from ' ./defaults/LoadingComponent' ;
16
21
import { DefaultNoDataComponent } from ' ./defaults/NoDataComponent' ;
@@ -333,6 +338,8 @@ The table initially contains 50 rows, when the last 10 rows are reached the tabl
333
338
</Story >
334
339
</Canvas >
335
340
341
+ ### Code
342
+
336
343
``` jsx
337
344
const InfiniteScrollTable = (props ) => {
338
345
const [data , setData ] = useState (props .data .slice (0 , 50 ));
@@ -363,3 +370,110 @@ const InfiniteScrollTable = (props) => {
363
370
);
364
371
};
365
372
```
373
+
374
+ ## AnalyticalTable with subcomponents
375
+
376
+ Adding custom subcomponents below table rows can be achieved by setting the ` renderRowSubComponent ` prop.
377
+ The prop expects a function with an optional parameter containing the ` row ` instance, there you can control which row should display subcomponents.
378
+
379
+ ** Note:** When ` renderRowSubComponent ` is set, ` grouping ` is disabled.
380
+
381
+ <Canvas >
382
+ <Story name = " with subcomponents" args = { { data: generateData (100 ) }} >
383
+ { (args ) => {
384
+ const renderRowSubComponent = (row ) => {
385
+ if (row .id === ' 0' ) {
386
+ return (
387
+ <FlexBox
388
+ style = { { backgroundColor: ' lightblue' , height: ' 300px' }}
389
+ justifyContent = { FlexBoxJustifyContent .Center }
390
+ alignItems = { FlexBoxAlignItems .Center }
391
+ direction = { FlexBoxDirection .Column }
392
+ >
393
+ <Badge >height: 300px</Badge >
394
+ <Text >This subcomponent will only be displayed below the first row.</Text >
395
+ </FlexBox >
396
+ );
397
+ }
398
+ if (row .id === ' 1' ) {
399
+ return (
400
+ <FlexBox
401
+ style = { { backgroundColor: ' lightyellow' , height: ' 100px' }}
402
+ justifyContent = { FlexBoxJustifyContent .Center }
403
+ alignItems = { FlexBoxAlignItems .Center }
404
+ direction = { FlexBoxDirection .Column }
405
+ >
406
+ <Badge >height: 100px</Badge >
407
+ <Text >This subcomponent will only be displayed below the second row.</Text >
408
+ </FlexBox >
409
+ );
410
+ }
411
+ if (row .id === ' 2' ) {
412
+ return null ;
413
+ }
414
+ return (
415
+ <FlexBox
416
+ style = { { backgroundColor: ' lightgrey' , height: ' 50px' }}
417
+ justifyContent = { FlexBoxJustifyContent .Center }
418
+ alignItems = { FlexBoxAlignItems .Center }
419
+ direction = { FlexBoxDirection .Column }
420
+ >
421
+ <Badge >height: 50px</Badge >
422
+ <Text >This subcomponent will be displayed below all rows except the first, second and third.</Text >
423
+ </FlexBox >
424
+ );
425
+ };
426
+ return <AnalyticalTable data = { args .data } columns = { args .columns } renderRowSubComponent = { renderRowSubComponent } />;
427
+ }}
428
+ </Story >
429
+ </Canvas >
430
+
431
+ ### Code
432
+
433
+ ``` jsx
434
+ const TableWithSubcomponents = (props ) => {
435
+ const renderRowSubComponent = (row ) => {
436
+ if (row .id === ' 0' ) {
437
+ return (
438
+ < FlexBox
439
+ style= {{ backgroundColor: ' lightblue' , height: ' 300px' }}
440
+ justifyContent= {FlexBoxJustifyContent .Center }
441
+ alignItems= {FlexBoxAlignItems .Center }
442
+ direction= {FlexBoxDirection .Column }
443
+ >
444
+ < Badge> height: 300px < / Badge>
445
+ < Text > This subcomponent will only be displayed below the first row.< / Text >
446
+ < / FlexBox>
447
+ );
448
+ }
449
+ if (row .id === ' 1' ) {
450
+ return (
451
+ < FlexBox
452
+ style= {{ backgroundColor: ' lightyellow' , height: ' 100px' }}
453
+ justifyContent= {FlexBoxJustifyContent .Center }
454
+ alignItems= {FlexBoxAlignItems .Center }
455
+ direction= {FlexBoxDirection .Column }
456
+ >
457
+ < Badge> height: 100px < / Badge>
458
+ < Text > This subcomponent will only be displayed below the second row.< / Text >
459
+ < / FlexBox>
460
+ );
461
+ }
462
+ if (row .id === ' 2' ) {
463
+ return null ;
464
+ }
465
+ return (
466
+ < FlexBox
467
+ style= {{ backgroundColor: ' lightgrey' , height: ' 50px' }}
468
+ justifyContent= {FlexBoxJustifyContent .Center }
469
+ alignItems= {FlexBoxAlignItems .Center }
470
+ direction= {FlexBoxDirection .Column }
471
+ >
472
+ < Badge> height: 50px < / Badge>
473
+ < Text > This subcomponent will be displayed below all rows except the first, second and third.< / Text >
474
+ < / FlexBox>
475
+ );
476
+ };
477
+ return < AnalyticalTable data= {props .data } columns= {props .columns } renderRowSubComponent= {renderRowSubComponent} / > ;
478
+ };
479
+ ```
0 commit comments