You need to sign in to do that
Don't have an account?

Get value from controller for every row of dataTable
I would like to apply different formatting for a column in a dataTable based on the value of one of the fields in the current record that the dataTable is displaying. Basically, I need to color-code the 'rows' of the data table based on the value of one of the fields.
I am currently doing this in the apex markup with an ugly, redundant set of 'IF' statments in the 'styleClass' attribute :
Ideally, I would like to create a method back in the controller which can return the proper styleClass value for each column. I can't seem to figure out how to pass these values back and forth while the dataTable is getting setup. Do I have to do some commandLink parameter passing and basically 're-render' each column with a roundtrip to the controller? Am I missing the simple way to do this??
Thanks.
I am currently doing this in the apex markup with an ugly, redundant set of 'IF' statments in the 'styleClass' attribute :
Code:
<apex:column headerValue="Description" style="text-align:left" width="20%" styleClass="{!if(Record.Investment_Status__c ='Exited', 'data1',if(Record.Investment_Status__c ='Portfolio Company', 'data2',if(Record.Investment_Status__c ='Signed Term Sheet', 'data3',if(Record.Investment_Status__c ='Terms Proposed', 'data4', if(Record.Investment_Status__c ='Due Dilligence', 'data5',if(Record.Investment_Status__c ='Visit- Multiple', 'data6',if(Record.Investment_Status__c ='Visit - Once', 'data7',if(Record.Investment_Status__c ='For Discussion', 'data8',if(Record.Investment_Status__c ='Conference Call', 'data9','color:black') ))))))))}"> <apex:outputText value="{!Record.Description}"/> </apex:column>
Ideally, I would like to create a method back in the controller which can return the proper styleClass value for each column. I can't seem to figure out how to pass these values back and forth while the dataTable is getting setup. Do I have to do some commandLink parameter passing and basically 're-render' each column with a roundtrip to the controller? Am I missing the simple way to do this??
Thanks.
Add a class wrapper around your SObject so that the dataTable is binding to an array of WrapperObjects.
This wrapper can then expose a StyleClass property as a function of it's child SObject which you can use.
Thanks for the note. I think I see what you are saying. I'll give this a shot and see how it works.
thanks for the insight. with your comments, and the excellent post from Ron Hess here: http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=766
I was able to do just exactly what I needed.
thanks!!
No worries,
Although I would love to see this ability in the future where we could bind to a method with parameters - i.e.