You need to sign in to do that
Don't have an account?
sanjeev342
How do I hide a dataTable by default?
I have a requirement where a datatable of clients must be hidden by default (i.e. on page load). The table appears and populates only when a certain command link is clicked. How do I go about achieving this?
This is the datatable I have so far:
<apex:dataTable id="clientDataTable" value="{!clientList}" var="clientRecord" width="100%"> <apex:column headerValue="Client Name" width="30%"> <apex:outputText value="{!clientRecord.Client_Name__c}"/> </apex:column> <apex:column headerValue="Description of Fund Raising Activities" width="30%"> <apex:outputField value="{!clientRecord.Description__c}"/> </apex:column> <apex:column headerValue="Start Date" width="20%"> <apex:outputText value="{!clientRecord.Start_Date__c}"/> </apex:column> <apex:column headerValue="End Date" width="20%" > <apex:outputText value="{!clientRecord.End_Date__c}"/> </apex:column> <apex:column headerValue="Pro-Bono" width="10%"> <apex:outputText value="{!IF(clientRecord.Pro_Bono__c, 'Yes', 'No')}"/> </apex:column> </apex:dataTable>
Thanks,
Sanjeev
One more ulternate i sees.
declare one Boolean varialbe in class.
Chang in class according to your requirement, i am just giving idea.
// put an output panel outside the table because we can not reRender an element which is having rendered condition. like this way
// reRender the <apex:outputPanel> using command link.
All Answers
Hi Sanjeev,
This we can achieve through CSS and jQuery.
1. Initially we will set Display CSS property none for the tale.
2. Now when user will click on command link we will call java script function. In this java script function we will change the Display CSS property none to block.
Thanks Shiv, I appreciate the help.
This makes sense, but it still doesn't work.
This is what my command link looks like:
And here's the javascript (the datatable name was changed):
And here's the beginning of the datatable:
I think the issue is that the javascript method is run, but the page is not able to access the controller method {!updateClientList}. Please let me know what you think.
Sanjeev
2. Are you invoking jQuery in your VF Page ?
Just check jQuery invoked or not.
<script type="text/javascript">
if($){
alert('jQuery Invoked');
} else { alert('jQuery not invoked') }
function displayClientTable(){
$('[Id $= "ClientRecordsTable"]').css('display','block');
}
</script>
One more ulternate i sees.
declare one Boolean varialbe in class.
Chang in class according to your requirement, i am just giving idea.
// put an output panel outside the table because we can not reRender an element which is having rendered condition. like this way
// reRender the <apex:outputPanel> using command link.
Hi Shiv,
Your solution is perfect. I also do the same thing for hiding and unhiding the controles.
apex:dataTable id="clientDataTable" value="{!clientList}" var="clientRecord" width="100%" rendered="{!(clientList.Size > 0)}"
and do the query on commandlink click using a method
Thanks! This works. You're right about the issue I was facing...couldn't reRender a control with a "rendered" attribute. Just encapsulating the table in another outputpanel seems to have done the trick!
Cheers,
Sanjeev