You need to sign in to do that
Don't have an account?
William Woodson 3
visualforce pages repeat without value
I want to generate a consistent number or rows in a table regardless of how many related objects exists (i.e. I want 7 rows even when there is only 3 related list objects).
I was trying to use a repeat without a value attribute to try to just create a generic looping behavior but that does not work. I am using a standard controller and didn't want to create an extension just to generate the other rows. Here is the code...
This does't work and I have scowered google with not resolution, any help would be greatly appreciated.
I was trying to use a repeat without a value attribute to try to just create a generic looping behavior but that does not work. I am using a standard controller and didn't want to create an extension just to generate the other rows. Here is the code...
<apex:variable var="rowNum" value="{!1}"/> <apex:repeat var="f" value="{!sow__c.Facilities__r}" rows="7"> <apex:variable var="rowNum" value="{!rowNum + 1}"/> <div class="row"> <div class="col-7"> <div class="row"> <div class="bodycell col-4"> <span>{!f.Account__r.Name}</span> </div> <div class="bodycell center col-2"> <span> <apex:outputText value="{0, number, 0}"> <apex:Param value="{!f.v1__c}" /> </apex:outputText> </span> </div> <div class="bodycell center col-2"> <span> <apex:outputText value="{0, number, 0}"> <apex:Param value="{!f.v2__c}" /> </apex:outputText> </span> </div> <div class="bodycell col-4"> <span>{!f.v3__c}</span> </div> </div> </div> <div class="bodycell col-5"> <span>{!f.v4__c}</span> </div> </div> </apex:repeat> <apex:repeat var="f" rows="{!(7 - rowNum)}"> <div class="row"> <div class="col-7"> <div class="row"> <div class="bodycell col-4"> <span> </span> </div> <div class="bodycell col-2"> <span> </span> </div> <div class="bodycell col-2"> <span> </span> </div> <div class="bodycell col-4"> <span> </span> </div> </div> </div> <div class="bodycell col-5"> <span> </span> </div> </div> </apex:repeat>
This does't work and I have scowered google with not resolution, any help would be greatly appreciated.
For dynamic "injection" of HTML code, JQuery is the easiest way.
<apex:variable var="rowNum" value="{!rowNum + 1}"/> is not easy to use in contrast.
The little script at the end of the page creates the missing rows and append them.
All Answers
For dynamic "injection" of HTML code, JQuery is the easiest way.
<apex:variable var="rowNum" value="{!rowNum + 1}"/> is not easy to use in contrast.
The little script at the end of the page creates the missing rows and append them.
So anyway thanks!!!
Interesting feedback (boostrap) .
<apex:variable> is often used (only option at the beginning) but the Salesforce documentation insists that counters based on it will be not reliable.
Note: <apex:variable> does not support reassignment inside of an iteration component, such as <apex:dataTable> or <apex:repeat>. The result of doing so, e.g., incrementing the <apex:variable> as a counter, is unsupported and undefined.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_variable.htm?search_text=counter
Nevertheless, we often try to increment this variable in VFP despite the warning and that could almost work sometimes.
Many questions here tried to use <apex:variable> as a counter (sometimes that works) but if you master jQuery now that will be always useful for other needs in VFP.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_javascript_libraries.htm