+ Start a Discussion
dj_saaspointdj_saaspoint 

Getting input fields from a nested table

I'm writing a VF page to implement the following business requirement.

 

Allow user to select multiple partner accounts.

For each line item associated with the current opportunity, allow user to enter a percentage split to a partner.

 

If the line items on the current opp are {foo, bar} and the partners selected are {acme, widgetCo} this implies generating a table such as this

 

Partner: acme     Prod   Split %

                                 foo        10

                                 bar         0

 

Partner: widgetCo Prod   Split %

                                 foo        20

                                 bar        25

 

Where split % numbers are entered by the user. I can render it as a datatable inside a datatable, but I the product split information about the partner "acme"

 

How do I do this in VF?

 

 

Message Edited by dj_saaspoint on 10-15-2009 08:13 AM
Best Answer chosen by Admin (Salesforce Developers) 
ThomasTTThomasTT

I actually tried the same thing with apex:pageBlockTable, and I could, but header styling was screwed up (not so much, but not perfect) because of the class / style definition.

 

Basically, you can do it with

 

<apex:page controller="YourController"> ... <apex:pageBlockTable value="{!rows}" var="r"> <apex:column value="{!r.a.Name}"/> <apex:column> <apex:pageBlockTable value="{!r.c}" var="c"> <apex:column value="{!c.Name}"/> <apex:column value="{!c.Email}"/> <apex:column value="{!c.Phone}"/> </apex:pageBlockTable> </apex:column> </apex:pageBlockTable> ... </apex:page>

 

 

 

 

public class YourController { public class Row { public Account a {get; set;} // or something like that public List<Contact> c {get; set;} // or something like that } public List<Row> getRows(){ .... return rows; } }

 

 In this case, the 2nd row doesn't render header and header line properly... somehow I have to override the class / style definition in my source code.

If somebody successfully did this, please post your solution.

 

ThomasTT

 

All Answers

ThomasTTThomasTT

I actually tried the same thing with apex:pageBlockTable, and I could, but header styling was screwed up (not so much, but not perfect) because of the class / style definition.

 

Basically, you can do it with

 

<apex:page controller="YourController"> ... <apex:pageBlockTable value="{!rows}" var="r"> <apex:column value="{!r.a.Name}"/> <apex:column> <apex:pageBlockTable value="{!r.c}" var="c"> <apex:column value="{!c.Name}"/> <apex:column value="{!c.Email}"/> <apex:column value="{!c.Phone}"/> </apex:pageBlockTable> </apex:column> </apex:pageBlockTable> ... </apex:page>

 

 

 

 

public class YourController { public class Row { public Account a {get; set;} // or something like that public List<Contact> c {get; set;} // or something like that } public List<Row> getRows(){ .... return rows; } }

 

 In this case, the 2nd row doesn't render header and header line properly... somehow I have to override the class / style definition in my source code.

If somebody successfully did this, please post your solution.

 

ThomasTT

 

This was selected as the best answer
dj_saaspointdj_saaspoint

Thanks Thomas.

 

That worked perfectly. I didn't realise you could have {!r.c} as a value on the inner table.

 

Cheers,

David.