You need to sign in to do that
Don't have an account?
Rick MacGuigan
How render apex column based on query results as true or false
I do not want to show a column in a data table if the respective field for all records returned in a query are empty .
For example, if the field PAID_LOSS__c in the result set is empty how can I render that column false ?
I render the page block if the entire result set is empty but need to also test each discrete field in order to not render a particular column within the data table.
For example, if the field PAID_LOSS__c in the result set is empty how can I render that column false ?
I render the page block if the entire result set is empty but need to also test each discrete field in order to not render a particular column within the data table.
<apex:pageBlockSection columns="1" id="section2c" title="* Expiring Contract Experience" showHeader="true" rendered="{!NOT(!PriorYRcontractSectionList.empty)}" > <apex:outputPanel id="out2c"> <apex:actionstatus startText="loading..."> <apex:facet name="stop" > <apex:outputPanel > <apex:dataTable style="text-align:right;" value="{!PriorYRcontractSectionList}" var="pyr" rules="all" cellpadding="5" > <apex:column value="{!pyr.Name}" headerValue="Contracts"/> <apex:column value="{!pyr.ULTIMATE_PREMIUM__c}" headerValue="Ult Prem"/> <apex:column value="{!pyr.PAID_LOSS__c}" headerValue="Ttl Rprd Loss" /> <apex:column value="{!pyr.ACR__c}" headerValue="Ttl ACR"/> <apex:column value="{!pyr.ULTIMATE_LOSS__c}" headerValue="Ttl Ult Loss Incl ACR"/> <apex:column value="{!pyr.Ultimate_Loss_Ratio__c}" headerValue="Ult LR%"/> <apex:column value="{!pyr.F_DETAIL_COMMISSION__c}" headerValue="Ult Comm%"/> <apex:column value="{!pyr.F_DETAIL_BROKERAGE__c}" headerValue="Ult Brok%"/> <apex:column value="{!pyr.ULT_OVERHEAD_EXCL_CATS__c}" headerValue="Ult OH%"/> <apex:column value="{!pyr.ULT_CR_ACCT_OH__c}" headerValue="Ult CR%"/> <apex:column value="{!pyr.ULT_CR_ACCT_EXCL_OH__c}" headerValue="Ult CR x OH%"/> <apex:column value="{!pyr.ITD_CR_EXCL_ACCT_OH__c}" headerValue="ITD CR x OH%"/> </apex:dataTable> </apex:outputPanel> </apex:facet> </apex:actionstatus> </apex:outputPanel> </apex:pageBlockSection> public List<MR_Contracts__c> BoundcontractQSSummaryList {get;set;} this.BoundcontractQSSummaryList = queryBoundQScontractsummaryById(contractNumbers, this.ContractYear); private List<MR_Contracts__c> queryBoundQScontractsummaryById(List<String> contractIds, string ContractYear) { return [ SELECT Id ,Name ,Renewal_Date__c ,Effective_Date__c ,SPD_RTC_CODE__c ,SUBJECT_PREMIUM_PS__c ,QUOTA_SHARE_PART_OF__c ,Limit__c ,Event_Limit__c ,Participation__c ,Estimated_Premium_PS__c ,Maiden_Re_Limit__c ,Attachment_Type__c ,RSO_LAE_TYPE__c ,RSO_ECO_PCNT__c ,RSO_XPL_PCNT__c ,F_DETAIL_COMMISSION__c ,PROFIT_COMM_RATE__c ,PROFIT_COMM_PNCT__c ,Ceding_Comm_Min__c ,Ceding_Comm_Prov__c ,Ceding_Comm_Max__c ,CEDING_COMM_INT__c ,CEDING_COMM_MIN_LR__c ,CEDING_COMM_PROV_LR__c ,CEDING_COMM_MAX_LR__c ,CEDING_COMM_INT_LR__c ,BROKERAGE__c ,CAT_LOAD_PCT__c ,PRICED_ULT_OVERHEAD_EXCL_CATS__c ,ROE_COMBINED_TARGET__c ,COMBINED_RATIO__c ,Priced_C_R_Excl_OH__c ,TARGET_ROE__c ,ROE__c FROM MR_Contracts__c WHERE ContractSubmissionRef__c IN :contractIds AND SPD_RTC_CODE__c LIKE '%QS%' ORDER BY Name DESC ]; }
and add this line just before begining to loop through the list of MRAccounts
Hope this helps!
AM
All Answers
My suggestion is add this rendered logic to the column for PAID_LOSS__c:
This will render the column if at least one of the values for field is not null (populated). Then in the controller add logic to determine if this variable is true or false. Something like this:
verify that the list actually doesnt contain only null values for this field right after you query for your data set. You can loop through the returned list of MR_Contracts__c to determine this instead of returning it right away.
This should get you the behavior you are looking for.
Hope this helps!
AM
and add this line just before begining to loop through the list of MRAccounts
Hope this helps!
AM
Some columns may have a null or “0” values so I tested out both. The trick is to assume rendering is false unless I find at least one record that has a value in the column . In this case rendering for the entire column gets set to true. If I have to do this for every table and column can I just manually add the field names to a map and loop thru it to get each field name and append a unique value to allNulls for applicable coumn rendering ? (i.e allNulls_8_1, allNulls_8_2,…)
<apex:column value="{!bcs.ROE__c}" headerValue="ROE" rendered="{!allNulls_8_1}" />
<apex:column value="{!bcs.ADD__c}" headerValue="ROE" rendered="{!allNulls_8_2}" />