function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jim MontgomeryJim Montgomery 

PageBlock Table row conditional styling based on page parameter value

I am trying to have the selected row highlighted when the select button is clicked.
Since there is no action associated with the select command link, the page refreshes after clicking select, thus erasing any styling not based on the parameter ConId.
I am trying to have the styling applied conditionally based on the page parameter ConId.

<apex:page standardController="Account"> <apex:form > <apex:pageblock > <apex:pageblocktable value="{!account.Contacts}" var="item"> <apex:column headerValue="Select"> <apex:commandLink > <Apex:Outputtext value="Select"/> <apex:Param name="ConId" value="{!item.id}"/> </apex:CommandLink> </apex:column> <apex:column value="{!item.name}" style="{!if(item.id='{!$CurrentPage.parameters.ConId}','color:red','color:black')}"/> <apex:Column value="{!item.title}"/> <apex:Column value="{!item.Phone}"/> <apex:Column value="{!item.email}"/> <apex:Column value="{!item.mobilephone}"/> <apex:Column value="{!item.Inactive__c}"/> <apex:Column value="{!item.id}"/> </apex:pageblockTable> </apex:Pageblock> <br/> <br/> <apex:OutputLink value="{!account.ContactCallURL1__c}{!$CurrentPage.parameters.ConId}{!account.ContactCallURL2__c}"> <apex:OutputText style="color:blue;" value="Next"/> </apex:OutputLink> strId = {!$CurrentPage.parameters.ConId} </apex:form> </apex:page>
Best Answer chosen by Jim Montgomery
Nayana KNayana K
<apex:column value="{!item.name}" style="color:{!if(item.id=$CurrentPage.parameters.ConId,'red','black')}"/>

Try this once....

All Answers

Nayana KNayana K
<apex:page standardController="Account"> 
	<apex:form > 
		<apex:pageblock > 
			<apex:pageblocktable value="{!account.Contacts}" var="item">
				<apex:column headerValue="Select"> 
					<apex:commandLink rerender="dummy"> 
						<Apex:Outputtext value="Select"/> 
						<apex:Param name="ConId" value="{!item.id}"/> 
					</apex:CommandLink> 
				</apex:column>
				<apex:column value="{!item.name}" style="{!if(item.id='{!$CurrentPage.parameters.ConId}','color:red','color:black')}"/> 
				<apex:Column value="{!item.title}"/> <apex:Column value="{!item.Phone}"/> 
				<apex:Column value="{!item.email}"/> 
				<apex:Column value="{!item.mobilephone}"/> 
				<apex:Column value="{!item.Inactive__c}"/> 
				<apex:Column value="{!item.id}"/>
			</apex:pageblockTable> 
		</apex:Pageblock>
		<br/> <br/> 
	<apex:OutputLink value="{!account.ContactCallURL1__c}{!$CurrentPage.parameters.ConId}{!account.ContactCallURL2__c}"> 
		<apex:OutputText style="color:blue;" value="Next"/> 
	</apex:OutputLink> 
</apex:form> 
</apex:page>

Please try adding rerender="SOMEDUMMYNAME" on commandlink and check once.
Jim MontgomeryJim Montgomery
If I add that, the refresh does not happen and the page parameter ConId is not set. I need a way to have the refresh occur, but on page load, look to see if the contactid in the table matches the ConId parameter, then highlight the row based on that match. Jim Montgomery Manager, Sales Intelligence Operations Wolters Kluwer Tax & Accounting 20101 Hamilton Ave. Torrance, CA 90502 877-346-7148 jim.montgomery@wolterskluwer.com
Nayana KNayana K
<apex:page standardController="Account"> 
	<apex:form id="frm"> 
		<apex:pageblock > 
			<apex:pageblocktable value="{!account.Contacts}" var="item">
				<apex:column headerValue="Select"> 
					<apex:commandLink rerender="frm"> 
						<Apex:Outputtext value="Select"/> 
						<apex:Param name="ConId" value="{!item.id}"/> 
					</apex:CommandLink> 
				</apex:column>
				<apex:column value="{!item.name}" style="{!if(item.id='{!$CurrentPage.parameters.ConId}','color:red','color:black')}"/> 
				<apex:Column value="{!item.title}"/> <apex:Column value="{!item.Phone}"/> 
				<apex:Column value="{!item.email}"/> 
				<apex:Column value="{!item.mobilephone}"/> 
				<apex:Column value="{!item.Inactive__c}"/> 
				<apex:Column value="{!item.id}"/>
			</apex:pageblockTable> 
		</apex:Pageblock>
		<br/> <br/> 
	<apex:OutputLink value="{!account.ContactCallURL1__c}{!$CurrentPage.parameters.ConId}{!account.ContactCallURL2__c}"> 
		<apex:OutputText style="color:blue;" value="Next"/> 
	</apex:OutputLink> 
</apex:form> 
</apex:page>

Try above code
Jim MontgomeryJim Montgomery
Each time I add a re-render attribute, the refresh stops working, and I don’t get the parameter set. This line of code does not work I need the if statement to be able to see the ConId parameter. If I remove the ‘’ from {!$Currenpage.parameters.ConId}, I get a “syntax error” displayed. Jim Montgomery Manager, Sales Intelligence Operations Wolters Kluwer Tax & Accounting 20101 Hamilton Ave. Torrance, CA 90502 877-346-7148 jim.montgomery@wolterskluwer.com
Nayana KNayana K
<apex:column value="{!item.name}" style="color:{!if(item.id=$CurrentPage.parameters.ConId,'red','black')}"/>

Try this once....
This was selected as the best answer
Jim MontgomeryJim Montgomery
Thank you!!! That worked. Jim Montgomery Manager, Sales Intelligence Operations Wolters Kluwer Tax & Accounting 20101 Hamilton Ave. Torrance, CA 90502 877-346-7148 jim.montgomery@wolterskluwer.com
Nayana KNayana K
Please mark this as solved