+ Start a Discussion
lalitaroralalitarora 

Datatable not showing filters after getting rerendered

Datatable not showing filters after getting rerendered, when i click button to rerender data table it loses it style and show compact data.


           <apex:commandButton value="Rerender table" action="{!abc}" rerender="tblWRsa" rendered="true"/>
         
    </apex:pageBlockButtons>
    <apex:pageBlockSection columns="1" id="pbs1">
          <apex:outputPanel id="panel_1">
               <apex:dataTable value="{!abc}" var="wrsa"  id="tblWRsa" >
......
....
               </apex:dataTable>
          </apex:outputPanel>
    </apex:pageBlockSection>
</apex:pageBlock>


Before User-added image


AfterUser-added image
Best Answer chosen by lalitarora
Nayana KNayana K
You may have to use oncomplete here...
<apex:commandButton value="Rerender table" action="{!abc}" rerender="tblWRsa" rendered="true" oncomplete = "showTable();"/>

function showTable()
{
// call the jquery/javacript method which structures the table. You might have used it on load.
}

All Answers

Nayana KNayana K
You may have to use oncomplete here...
<apex:commandButton value="Rerender table" action="{!abc}" rerender="tblWRsa" rendered="true" oncomplete = "showTable();"/>

function showTable()
{
// call the jquery/javacript method which structures the table. You might have used it on load.
}
This was selected as the best answer
lalitaroralalitarora
Thanks Nayana, I tried to do as said above.

<!--<apex:page standardController="STG_Subscription_Asset_Item__c" extensions="VBSubscriptionAssetSelectorController">-->
<apex:page controller="Controllerabc" tabStyle="Account">

        <apex:includescript value="//code.jquery.com/jquery-1.12.3.min.js" / >
        <apex:includescript value="//cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js" />
        <apex:stylesheet value="//cdn.datatables.net/1.10.12/css/jquery.dataTables.css" />

.....

included new function

<script type="text/javascript">
    
function loadTableStyle()
{
         <apex:includescript value="//code.jquery.com/jquery-1.12.3.min.js" / >
        <apex:includescript value="//cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js" />
        <apex:stylesheet value="//cdn.datatables.net/1.10.12/css/jquery.dataTables.css" />
}    
</script>


<apex:commandButton value="rerendertable" action="{!function}" rerender="tblWRsa" styleClass="display" rendered="true" oncomplete="loadTableStyle();"/>

this is the datatable..
 <apex:dataTable value="{!list}" var="wrsa"  id="tblWRsa" styleClass="display">


Its still not working with above changes. What wrong am doing here?
 
Nayana KNayana K
includng script in the method is wrong way.....

Can u please post original code ( whole page code) once....I will find out what to be done
lalitaroralalitarora
Thanks Nayana. I got your point after looking into below post. Have marked your Answer best..

http://salesforce.stackexchange.com/questions/82313/jquery-not-initialised-after-rerender