You need to sign in to do that
Don't have an account?
Visweswara Rao Pamala
Dynamically add rows to vf page
Hi all,
Can you please help me how to add rows dynamically in vf page based on record getting in query in controller.
Below is the code iam using, in this currently adding one row, but need to add rows based on the record getting in SQL query.
VF page:
<apex:page standardController="Opportunity" extensions="ListsControllernew">
<apex:form >
<apex:pageBlock title="Files">
<apex:pageBlockButtons location="top" >
<apex:commandButton value="Upload Files" />
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!oppname}" var="acc">
<apex:column headerValue="Action" value="{!oppname}" />
<apex:column headerValue="Title" value="{!title}" />
<apex:column headerValue="Last Modified by" value="{!Modified}" />
<apex:column headerValue="Is Locked" value="{!Lockvalue}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class ListsControllernew {
private final Opportunity opp;
public string title{get; set;}
public String Modified{get; set;}
public String Lockvalue{get; set;}
public String oppname {get; set;}
public ListsControllernew(ApexPages.StandardController stdController) {
this.opp= (Opportunity)stdController.getRecord();
system.debug('id:'+opp.id);
//List<Opportunity> customObjects =[select name from Opportunity where Id=:opp.id];
//SELECT ContentDocumentId, FROM ContentDocumentLink WHERE LinkedEntityId = '[RECORD ID]'
integer count = [SELECT count()FROM ContentDocumentLink WHERE LinkedEntityId =: opp.id];
system.debug('Count:'+count);
List<ContentDocumentLink> customObjects = [SELECT Id, ContentDocumentId, ContentDocument.LatestPublishedVersionId, ContentDocument.Title, ContentDocument.CreatedById, ContentDocument.LastModifiedDate FROM ContentDocumentLink WHERE LinkedEntityId =: opp.id];
for (ContentDocumentLink rec: customObjects)
{
oppname = rec.ContentDocument.Title;
title=rec.ContentDocument.Title;
Modified=rec.ContentDocument.CreatedById;
Lockvalue= rec.ContentDocument.CreatedById;
}
}
}
Thanks.
Can you please help me how to add rows dynamically in vf page based on record getting in query in controller.
Below is the code iam using, in this currently adding one row, but need to add rows based on the record getting in SQL query.
VF page:
<apex:page standardController="Opportunity" extensions="ListsControllernew">
<apex:form >
<apex:pageBlock title="Files">
<apex:pageBlockButtons location="top" >
<apex:commandButton value="Upload Files" />
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!oppname}" var="acc">
<apex:column headerValue="Action" value="{!oppname}" />
<apex:column headerValue="Title" value="{!title}" />
<apex:column headerValue="Last Modified by" value="{!Modified}" />
<apex:column headerValue="Is Locked" value="{!Lockvalue}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class ListsControllernew {
private final Opportunity opp;
public string title{get; set;}
public String Modified{get; set;}
public String Lockvalue{get; set;}
public String oppname {get; set;}
public ListsControllernew(ApexPages.StandardController stdController) {
this.opp= (Opportunity)stdController.getRecord();
system.debug('id:'+opp.id);
//List<Opportunity> customObjects =[select name from Opportunity where Id=:opp.id];
//SELECT ContentDocumentId, FROM ContentDocumentLink WHERE LinkedEntityId = '[RECORD ID]'
integer count = [SELECT count()FROM ContentDocumentLink WHERE LinkedEntityId =: opp.id];
system.debug('Count:'+count);
List<ContentDocumentLink> customObjects = [SELECT Id, ContentDocumentId, ContentDocument.LatestPublishedVersionId, ContentDocument.Title, ContentDocument.CreatedById, ContentDocument.LastModifiedDate FROM ContentDocumentLink WHERE LinkedEntityId =: opp.id];
for (ContentDocumentLink rec: customObjects)
{
oppname = rec.ContentDocument.Title;
title=rec.ContentDocument.Title;
Modified=rec.ContentDocument.CreatedById;
Lockvalue= rec.ContentDocument.CreatedById;
}
}
}
Thanks.
Please refer below sample code which includes add row functionality to bulk update the records.
Hope this helps you!
If this helps you please mark it as BestAnswer so that it will make available for others as a proper solution.
Thanks and Regards
Sandhya