@@ -25,8 +25,8 @@ import {
2525 entityIsPersistable
2626} from "@jeltemx/mendix-react-widget-utils" ;
2727import { 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" ;
3030import { TableRecord } from "./util/table" ;
3131import { getObject } from "@jeltemx/mendix-react-widget-utils" ;
3232import { ValidateExtraProps , validateProps } from "./util/validation" ;
@@ -263,17 +263,52 @@ class DynamicTable extends Component<DynamicTableContainerProps> {
263263 columnSortingAttribute
264264 } = this . props ;
265265 if ( axis === "row" ) {
266- this . store . setRows ( objects , this . rowChildReference , this . hasChildAttr , parent , clean , {
266+ const tableOptions : TableObjectGetOptions = {
267267 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 ) ;
271288 } else {
272- this . store . setColumns ( objects , {
289+ const tableOptions : TableObjectGetOptions = {
273290 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 ) ;
277312 }
278313 }
279314
@@ -282,11 +317,25 @@ class DynamicTable extends Component<DynamicTableContainerProps> {
282317 attribute : string ,
283318 nanoflow : Nanoflow ,
284319 nodeType : NodeType = "unknown"
285- ) : TitleMethod {
320+ ) : TitleMethod | StaticTitleMethod {
286321 const renderAsHTML =
287322 ( this . props . rowRenderAsHTML && nodeType === "row" ) ||
288323 ( this . props . columnRenderAsHTML && nodeType === "column" ) ||
289324 ( 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+ }
290339 return ( obj : mendix . lib . MxObject ) : Promise < ReactNode > =>
291340 getTitleFromObject ( obj , {
292341 attribute,
@@ -486,10 +535,33 @@ class DynamicTable extends Component<DynamicTableContainerProps> {
486535
487536 if ( entryObjects ) {
488537 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+ ) ;
493565 } else {
494566 return entryObjects ;
495567 }
@@ -541,10 +613,34 @@ class DynamicTable extends Component<DynamicTableContainerProps> {
541613 const entries = await this . entriesLoad ( guids , false ) ;
542614 if ( entries ) {
543615 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+ ) ;
548644 }
549645 }
550646 this . store . setLoading ( false ) ;
0 commit comments