@@ -25,8 +25,8 @@ import {
25
25
entityIsPersistable
26
26
} from "@jeltemx/mendix-react-widget-utils" ;
27
27
import { createHelperObject } from "./util/helperobject" ;
28
- import { getTitleFromObject , ClickCellType } from "./util/titlehelper" ;
29
- import { TitleMethod } from "./store/objects/abstract/table-object" ;
28
+ import { getTitleFromObject , ClickCellType , getStaticTitleFromObject } from "./util/titlehelper" ;
29
+ import { TitleMethod , TableObjectGetOptions , StaticTitleMethod } from "./store/objects/abstract/table-object" ;
30
30
import { TableRecord } from "./util/table" ;
31
31
import { getObject } from "@jeltemx/mendix-react-widget-utils" ;
32
32
import { ValidateExtraProps , validateProps } from "./util/validation" ;
@@ -263,17 +263,52 @@ class DynamicTable extends Component<DynamicTableContainerProps> {
263
263
columnSortingAttribute
264
264
} = this . props ;
265
265
if ( axis === "row" ) {
266
- this . store . setRows ( objects , this . rowChildReference , this . hasChildAttr , parent , clean , {
266
+ const tableOptions : TableObjectGetOptions = {
267
267
classMethod : this . getClassMethod ( rowClassAttr ) ,
268
- sortMethod : this . getSortMethod ( rowSortingAttribute ) ,
269
- titleMethod : this . getTitleMethod ( rowTitleType , rowTitleAttr , rowTitleNanoflow , "row" )
270
- } ) ;
268
+ sortMethod : this . getSortMethod ( rowSortingAttribute )
269
+ } ;
270
+
271
+ if ( rowTitleType === "attribute" && rowTitleAttr ) {
272
+ tableOptions . staticTitleMethod = this . getTitleMethod (
273
+ rowTitleType ,
274
+ rowTitleAttr ,
275
+ rowTitleNanoflow ,
276
+ "row"
277
+ ) as StaticTitleMethod ;
278
+ } else {
279
+ tableOptions . titleMethod = this . getTitleMethod (
280
+ rowTitleType ,
281
+ rowTitleAttr ,
282
+ rowTitleNanoflow ,
283
+ "row"
284
+ ) as TitleMethod ;
285
+ }
286
+
287
+ this . store . setRows ( objects , this . rowChildReference , this . hasChildAttr , parent , clean , tableOptions ) ;
271
288
} else {
272
- this . store . setColumns ( objects , {
289
+ const tableOptions : TableObjectGetOptions = {
273
290
classMethod : this . getClassMethod ( columnClassAttr ) ,
274
- sortMethod : this . getSortMethod ( columnSortingAttribute ) ,
275
- titleMethod : this . getTitleMethod ( columnTitleType , columnTitleAttr , columnTitleNanoflow , "column" )
276
- } ) ;
291
+ sortMethod : this . getSortMethod ( columnSortingAttribute )
292
+ // titleMethod: this.getTitleMethod(columnTitleType, columnTitleAttr, columnTitleNanoflow, "column")
293
+ } ;
294
+
295
+ if ( columnTitleType === "attribute" && columnTitleAttr ) {
296
+ tableOptions . staticTitleMethod = this . getTitleMethod (
297
+ columnTitleType ,
298
+ columnTitleAttr ,
299
+ columnTitleNanoflow ,
300
+ "column"
301
+ ) as StaticTitleMethod ;
302
+ } else {
303
+ tableOptions . titleMethod = this . getTitleMethod (
304
+ columnTitleType ,
305
+ columnTitleAttr ,
306
+ columnTitleNanoflow ,
307
+ "column"
308
+ ) as TitleMethod ;
309
+ }
310
+
311
+ this . store . setColumns ( objects , tableOptions ) ;
277
312
}
278
313
}
279
314
@@ -282,11 +317,25 @@ class DynamicTable extends Component<DynamicTableContainerProps> {
282
317
attribute : string ,
283
318
nanoflow : Nanoflow ,
284
319
nodeType : NodeType = "unknown"
285
- ) : TitleMethod {
320
+ ) : TitleMethod | StaticTitleMethod {
286
321
const renderAsHTML =
287
322
( this . props . rowRenderAsHTML && nodeType === "row" ) ||
288
323
( this . props . columnRenderAsHTML && nodeType === "column" ) ||
289
324
( this . props . entryRenderAsHTML && nodeType === "entry" ) ;
325
+
326
+ if ( titleType === "attribute" && attribute ) {
327
+ return ( obj : mendix . lib . MxObject ) : ReactNode =>
328
+ getStaticTitleFromObject ( obj , {
329
+ attribute,
330
+ executeAction : this . executeAction ,
331
+ nanoflow,
332
+ titleType,
333
+ nodeType,
334
+ onClickMethod : ( ) => this . clickTypeHandler ( obj , nodeType , "single" ) ,
335
+ onDoubleClickMethod : ( ) => this . clickTypeHandler ( obj , nodeType , "double" ) ,
336
+ renderAsHTML
337
+ } ) ;
338
+ }
290
339
return ( obj : mendix . lib . MxObject ) : Promise < ReactNode > =>
291
340
getTitleFromObject ( obj , {
292
341
attribute,
@@ -486,10 +535,33 @@ class DynamicTable extends Component<DynamicTableContainerProps> {
486
535
487
536
if ( entryObjects ) {
488
537
if ( setStore ) {
489
- this . store . setEntries ( entryObjects , this . entryRowReference , this . entryColumnReference , clean , {
490
- classMethod : this . getClassMethod ( entryClassAttr ) ,
491
- titleMethod : this . getTitleMethod ( entryTitleType , entryTitleAttr , entryTitleNanoflow , "entry" )
492
- } ) ;
538
+ const entriesOptions : TableObjectGetOptions = {
539
+ classMethod : this . getClassMethod ( entryClassAttr )
540
+ } ;
541
+
542
+ if ( entryTitleType === "attribute" && entryTitleAttr ) {
543
+ entriesOptions . staticTitleMethod = this . getTitleMethod (
544
+ entryTitleType ,
545
+ entryTitleAttr ,
546
+ entryTitleNanoflow ,
547
+ "entry"
548
+ ) as StaticTitleMethod ;
549
+ } else {
550
+ entriesOptions . titleMethod = this . getTitleMethod (
551
+ entryTitleType ,
552
+ entryTitleAttr ,
553
+ entryTitleNanoflow ,
554
+ "entry"
555
+ ) as TitleMethod ;
556
+ }
557
+
558
+ this . store . setEntries (
559
+ entryObjects ,
560
+ this . entryRowReference ,
561
+ this . entryColumnReference ,
562
+ clean ,
563
+ entriesOptions
564
+ ) ;
493
565
} else {
494
566
return entryObjects ;
495
567
}
@@ -541,10 +613,34 @@ class DynamicTable extends Component<DynamicTableContainerProps> {
541
613
const entries = await this . entriesLoad ( guids , false ) ;
542
614
if ( entries ) {
543
615
const { entryTitleType, entryTitleAttr, entryTitleNanoflow, entryClassAttr } = this . props ;
544
- this . store . setEntries ( entries , this . entryRowReference , this . entryColumnReference , false , {
545
- classMethod : this . getClassMethod ( entryClassAttr ) ,
546
- titleMethod : this . getTitleMethod ( entryTitleType , entryTitleAttr , entryTitleNanoflow , "entry" )
547
- } ) ;
616
+
617
+ const entriesOptions : TableObjectGetOptions = {
618
+ classMethod : this . getClassMethod ( entryClassAttr )
619
+ } ;
620
+
621
+ if ( entryTitleType === "attribute" && entryTitleAttr ) {
622
+ entriesOptions . staticTitleMethod = this . getTitleMethod (
623
+ entryTitleType ,
624
+ entryTitleAttr ,
625
+ entryTitleNanoflow ,
626
+ "entry"
627
+ ) as StaticTitleMethod ;
628
+ } else {
629
+ entriesOptions . titleMethod = this . getTitleMethod (
630
+ entryTitleType ,
631
+ entryTitleAttr ,
632
+ entryTitleNanoflow ,
633
+ "entry"
634
+ ) as TitleMethod ;
635
+ }
636
+
637
+ this . store . setEntries (
638
+ entries ,
639
+ this . entryRowReference ,
640
+ this . entryColumnReference ,
641
+ false ,
642
+ entriesOptions
643
+ ) ;
548
644
}
549
645
}
550
646
this . store . setLoading ( false ) ;
0 commit comments