• jdeveloper
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 2
    Replies

Hi guys i was wondering how to add rows in a pageblock table. for example you want to make a to-do list. each row is a task.  The columns of the table are task(DropDown list), Deadline(Date), Hours worked(Double). If you want to add a task you click on the Add Row button and adds a  row to the table.

hi, i have this table in my visual force page. the fist column of the table is a select option and the others are text. I have a button "add row". This button adds a row to the table, however, because the table needs to be rerendered for the table to show the new row. This causes all select options to go back to the default value. How can you make it so when u click add row each row still has its original select option from before and not the default value. here is the code

<apex:page>
<apex:form > 
    <apex:pageblock>
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}" rerender="error"/>
            <apex:commandButton value="Cancel" action="{!cancel}" rerender="error"/>
        </apex:pageBlockButtons>
  
        <apex:pageblockTable value="{!sblogs}" var="sb" id="table">
         
         	
            <apex:column headerValue="Sold Item" style="width:110px;border:1px solid #f3f3eb;">
                <apex:selectList multiselect="false"   size="1" value="{!sb.Sold_Item__c}" style="width:400px;">  
                        <apex:selectOptions value="{!GetSoldItems}"/>
                </apex:selectList>
            </apex:column>
            
          
            
                          
            <apex:column headerValue="Assigned To">
                <apex:inputField value="{!sb.Assigned_To__c}" required="true"/>
            </apex:column>
            <apex:column headerValue="Hours Worked">
                <apex:inputField value="{!sb.Hours_Worked__c}" style="width:3em;"/>
            </apex:column>
            <apex:column headerValue="Percent Complete">
                <apex:inputField value="{!sb.Percent_Complete__c}" style="width:3em;"/>
            </apex:column>
            <apex:column headerValue="Cost">
                <apex:inputField value="{!sb.Cost__c}"/>
            </apex:column>
        </apex:pageblockTable>
        
        <apex:pageblockButtons location="bottom">
            <div style="text-align:right;margin-right:30px;font-weight:bold;">
                <apex:commandLink value="Add Row" action="{!addRow}" rerender="table,error" immediate="true" />
                &nbsp;|&nbsp;&nbsp;
                <apex:commandLink value="Remove Row" action="{!removeRow}" rerender="table,error" immediate="true" />                
            </div>
        </apex:pageblockButtons>
    </apex:pageblock>  
</apex:form>
</apex:page>

 

public with sharing class BacklogContExt {

    public List<Backlog__c> sblogs {get; set;}
    public final print__c parprint;
    
    public BacklogContExt(ApexPages.StandardController myController) {
        //parprint=(print__c)myController.getrecord();
        
      
        parprint=[Select ID,Name
        from print__c 
        WHERE ID = :((print__c)myController.getrecord()).ID];
        
        setSoldItems(parprint);  
        
        sblogs = new List<Backlog__c>();
        Backlog__c SBacklog = new Backlog__c();
        SBacklog.print__c = parprint.Id;
        sblogs.add(SBacklog);
       
      
        
        
        }//end of constructor

    public void addrow() {
        Backlog__c SBacklog = new Backlog__c();
        SBacklog.print__c = parprint.Id;
        sblogs.add(SBacklog);}
            
    public void removerow(){
        Integer i = sblogs.size();
        sblogs.remove(i-1);}
            
    public PageReference save() {
        insert sblogs;
        PageReference parrec = new PageReference ('/'+parprint.id);
        parrec.setRedirect(true);
        return parrec; 
        }
        
    public PageReference cancel() {
        PageReference parrec = new PageReference ('/'+paSprint.id);
        parrec.setRedirect(true);
        return parrec; 
        }    
        
 /* Begin Select option */
 
 List<SelectOption>  SelectListOfSoldItems= new List<SelectOption>();
        public  List<SelectOption> GetSoldItems{  
             
             get{         
             	 return SelectListOfSoldItems;
             }    
             
             private set;        
        }
     Private void setSoldItems(print__c print){   
            SelectListOfSoldItems.CLEAR();            
              
            for (Sold_Item__c SoldItem:[SELECT ID,Name 
                                        FROM Sold_item__c 
                                        WHERE
                                        Completion__c <> 100.0
                                        AND  Sold_Item__c.Project__r.name=:parprint.Project__c
                                        ]){
                                        
               SelectListOfSoldItems.ADD(new SelectOption(SoldItem.id, SoldItem.Name));                                        
           }                                      
        }

 

I have an object called book. I want to make a custom button for the book__c object called sell. If the book has been sold(book__c.book_Status__c == 'Sold') a message will display saying that the book has been sold. otherwise the button will take you to another visualforce page called book sell. does anyone have any suggestions.

hi, I have this object book and a custom field comments__c. i want a user to be able to enter comments about the book in another page and view the comments of the book in another page. my controller is something like this

public class bookComments{

public String bookComments {get;set;}
public List<auction__c> auctions;
public List<String> bookIds = new List<String>();

public List<auction__c> getmybook(){

 

  auctions = [Select id, Name, BookAuctionId__c from action__c where id =: BookAuctionsId__c];

return auctions;

}

public PageReference acceptBookComments(){

for (auction__c b: auctions){
bookIds.add(c.id);
}
public List<books__c> mybooks = [Select id, Name, comments__c, bookAuctionsId__c from books__c where bookAuctionId__c IN bookIds ]

for (auction__c c: auctions){

mybooks.comments = bookComments
}

update mybooks;

}


}

 Then the visualforce page is like this.

<apex:page>
<apex:form>
<apex:dataTable var="auction" value="{!mybook}">
<column>
<apex:outputField value="{!auction.Name}"/>
</column>

<column>
apex:inputTextarea value="{!bookComments}"/>
</column>

</apex:dataTable>

</apex:form>
</apex:page>



Then i have another page that is supposed to show the comments entered.

<apex:page>
<apex:form>
<apex:dataTable var="books" value="{!showComments}">
<apex:outputField value="{!books.comments__c}"/>

</apex:dataTable>
</apex:form>
</apex:page>

 Sometimes it works, sometimes it doesnt

 

 

hi lets say we have trigger that is triggered when object__c is update. then what does for (Object__c c: Trigger.New) mean. Is it a for each loop that goes through every record that has just been updated for the object__c

hi, im new to salesforce and i was wondering what was the difference between __c and __r when refering to a custom object. Also can u give me examples. thanks

hi, im new to salesforce and i was wondering what was the difference between __c and __r when refering to a custom object. Also can u give me examples. thanks

I have an object called book. I want to make a custom button for the book__c object called sell. If the book has been sold(book__c.book_Status__c == 'Sold') a message will display saying that the book has been sold. otherwise the button will take you to another visualforce page called book sell. does anyone have any suggestions.

hi, I have this object book and a custom field comments__c. i want a user to be able to enter comments about the book in another page and view the comments of the book in another page. my controller is something like this

public class bookComments{

public String bookComments {get;set;}
public List<auction__c> auctions;
public List<String> bookIds = new List<String>();

public List<auction__c> getmybook(){

 

  auctions = [Select id, Name, BookAuctionId__c from action__c where id =: BookAuctionsId__c];

return auctions;

}

public PageReference acceptBookComments(){

for (auction__c b: auctions){
bookIds.add(c.id);
}
public List<books__c> mybooks = [Select id, Name, comments__c, bookAuctionsId__c from books__c where bookAuctionId__c IN bookIds ]

for (auction__c c: auctions){

mybooks.comments = bookComments
}

update mybooks;

}


}

 Then the visualforce page is like this.

<apex:page>
<apex:form>
<apex:dataTable var="auction" value="{!mybook}">
<column>
<apex:outputField value="{!auction.Name}"/>
</column>

<column>
apex:inputTextarea value="{!bookComments}"/>
</column>

</apex:dataTable>

</apex:form>
</apex:page>



Then i have another page that is supposed to show the comments entered.

<apex:page>
<apex:form>
<apex:dataTable var="books" value="{!showComments}">
<apex:outputField value="{!books.comments__c}"/>

</apex:dataTable>
</apex:form>
</apex:page>

 Sometimes it works, sometimes it doesnt