@@ -14,6 +14,26 @@ public with sharing class RelatedList {
1414 public Boolean editable ;
1515 @AuraEnabled
1616 public Boolean sortable ;
17+ @AuraEnabled
18+ public Boolean wrapText = false ;
19+ @AuraEnabled
20+ public TypeAttributeColumnJsonWithPicklist typeAttributes = null ;
21+
22+ public void setTypeAttributes (List <PicklistColumnUtils .PicklistValue > options ) {
23+ this .typeAttributes = new TypeAttributeColumnJsonWithPicklist ();
24+ this .typeAttributes .options = options ;
25+ this .typeAttributes .fieldName = this .fieldName ;
26+ }
27+ }
28+
29+ public class TypeAttributeColumnJsonWithPicklist {
30+ @AuraEnabled public List <PicklistColumnUtils .PicklistValue > options = new List <PicklistColumnUtils .PicklistValue >();
31+ @AuraEnabled public ContextTypeAttributeColumnJsonWithPicklist context = new ContextTypeAttributeColumnJsonWithPicklist ();
32+ @AuraEnabled public String fieldName ;
33+ }
34+
35+ public class ContextTypeAttributeColumnJsonWithPicklist {
36+ @AuraEnabled public string fieldName = ' Id' ;
1737 }
1838
1939 public class ListResults {
@@ -65,7 +85,13 @@ public with sharing class RelatedList {
6585 // Check if values predefined in LWC
6686 if (mapPreCols .containsKey (fieldName )) {
6787 mapPreCols = checkOverride (mapPreCols , fieldName , mfields );
88+
89+ // set picklistValues for picklist type
90+ if (mapPreCols .get (fieldName ).type == ' picklist' ) {
91+ RelatedList .initPicklistColumn (mapPreCols , objectName , fieldName );
92+ }
6893 }
94+
6995 }
7096 return new ListResults (
7197 getRecords (soql ),
@@ -77,6 +103,12 @@ public with sharing class RelatedList {
77103 throw new AuraHandledException (e .getMessage ());
78104 }
79105 }
106+
107+ public static void initPicklistColumn (Map <String , ColumnJson > mapPreCols , String objectName , String fieldName ) {
108+ List <PicklistColumnUtils .PicklistValue > picklistValues = PicklistColumnUtils .getPicklistValues (objectName , fieldName );
109+ mapPreCols .get (fieldName ).wrapText = true ;
110+ mapPreCols .get (fieldName ).setTypeAttributes (picklistValues );
111+ }
80112
81113 @AuraEnabled
82114 public static List <SObject > getRecords (String soql ) {
@@ -111,16 +143,10 @@ public with sharing class RelatedList {
111143
112144 @AuraEnabled(cacheable= true )
113145 public static Integer countRecords (String objectName , String whereClause ) {
114- String formattedWhere = (String .isBlank (whereClause ))
115- ? ' '
116- : ' ' + whereClause ;
117- if (String .isNotEmpty (objectName )) {
118- return database .countQuery (
119- ' SELECT count() FROM ' +
120- objectName +
121- formattedWhere +
122- ' WITH SECURITY_ENFORCED'
123- );
146+ String formattedWhere = (String .isBlank (whereClause )) ? ' ' : ' ' + whereClause ;
147+
148+ if (String .isNotEmpty (objectName )) {
149+ return database .countQuery (' SELECT count() FROM ' + objectName + formattedWhere + ' WITH SECURITY_ENFORCED' );
124150 }
125151 return 0 ;
126152 }
@@ -140,9 +166,7 @@ public with sharing class RelatedList {
140166 Boolean editable = mapPreCols .get (fieldName ).editable != null
141167 ? mapPreCols .get (fieldName ).editable
142168 : mfields .get (fieldName ).getDescribe ().isUpdateable (),
143- sortable = mapPreCols .get (fieldName ).sortable != null
144- ? mapPreCols .get (fieldName ).sortable
145- : mfields .get (fieldName ).getDescribe ().isSortable ();
169+ sortable = true ;
146170 // Update Map Json
147171 mapPreCols .get (fieldName ).label = label ;
148172 mapPreCols .get (fieldName ).type = mapFieldToLwcDataType .containskey (type )
@@ -151,5 +175,5 @@ public with sharing class RelatedList {
151175 mapPreCols .get (fieldName ).editable = editable ;
152176 mapPreCols .get (fieldName ).sortable = sortable ;
153177 return mapPreCols ;
154- }
155- }
178+ }
179+ }
0 commit comments