0

Following is my code where in i wanted to do pagination for Datatable.

<apex:page id="page" standardController="Error_Log__c"  extensions="errorLogController_Check_MDSR" sidebar="false" showHeader="false" standardStylesheets="true" >
  <apex:slds />

      <script type="text/javascript" charset="utf8" src="https://code.jquery.com/jquery-1.12.4.js"></script>
      <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
      <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css"/>  

<!--
  <apex:includeScript value="{!$Resource.TableJS}"/>
  <apex:stylesheet value="{!$Resource.TableCSS}"/>
-->
      <script type="text/javascript">
        $(document).ready(function() {
            $('#DataTableBlock1').DataTable();
        } );
      </script>

  <apex:form >
    <apex:pageBlock title="Interfaces" id="pgblock">
      <apex:pageBlockSection >
        <apex:inputField value="{!interfaceDate.CriteriaStartDate_MDSR__c}" label="Date" styleClass="slds-input">
          <apex:actionSupport action="{!pageReload}" event="onchange" reRender="interfacepb,errorLogs"/>
        </apex:inputField>
        <apex:inputField value="{!interfaceDate.Interface_Type__c}" label="Interface Type" styleClass="slds-input">
          <apex:actionSupport action="{!pageReload}" event="onchange" reRender="interfacepb,errorLogs"/>
        </apex:inputField>
      </apex:pageBlockSection>

    <apex:pageBlockTable value="{!errWrpList}" var="recs" id="interfacepb" styleClass="slds-table slds-table--bordered slds-table--cell-buffer" >
      <apex:column >
        <apex:facet name="header">Interface Name</apex:facet>
        <apex:commandLink value="{!recs.interfaceName}" id="interfaceName" action="{!errorLogs}" reRender="errorLogs">
          <apex:param name="testParam"  value="{!recs.interfaceName}" />
          <apex:param name="recordCountSelRec"  value="{!recs.recordsCount}" />  
        </apex:commandLink>
        <!-- <apex:actionSupport action="{!errorLogs}" event="Onclick" reRender="errorLogs"/>                        -->
      </apex:column>
      <apex:column value="{!recs.recordsCount}" headerValue="Number of Transaction"/>      
      <apex:column value="{!recs.sendRecordSum}" headerValue="Sent Records" />
      <apex:column value="{!recs.failedSum}" headerValue="Failed Records"/>
      <apex:column value="{!recs.processedRec}" headerValue="Processed Records"/>
      <apex:column >
        <apex:facet name="header">Interface Type</apex:facet>
        <apex:outputText value="{!recs.interfaceType}"/>
        <apex:param name="setFieldSet"  value="{!recs.interfaceType}"/>
      </apex:column>
    </apex:pageBlockTable>
    </apex:pageBlock> 
    </apex:form>    
  <apex:pageBlock title="Error Logs" id="errorLogs">
    <apex:pageblocktable style="overflow:Auto;" value="{!errorLogsRec}" var="record" rendered="{!IF( interfaceTypevar=='Batch Integration',true,false)}" id="DataTableBlock1">
      <apex:repeat value="{!$ObjectType.Error_Log__c.FieldSets.Batch_Interface}" var="fieldAPIName">
        <apex:column value="{!record[fieldAPIName]}"/>
      </apex:repeat>

    </apex:pageblocktable>
    <apex:Datatable value="{!errorLogsRec}" var="record" rendered="{!IF( interfaceTypevar=='Real-Time',true,false)}" id="example">
      <apex:repeat value="{!$ObjectType.Error_Log__c.FieldSets.RealTime}" var="fieldAPIName">
        <apex:column value="{!record[fieldAPIName]}"/>
      </apex:repeat>
    </apex:Datatable>
    <apex:Datatable value="{!errorLogsRec}" var="record" rendered="{!IF( interfaceTypevar=='Lot Batch',true,false)}" id="DataTableBlock2">
      <apex:repeat value="{!$ObjectType.Error_Log__c.FieldSets.Lot_Batch}" var="fieldAPIName">
        <apex:column value="{!record[fieldAPIName]}"/>
      </apex:repeat>
    </apex:Datatable>        
  </apex:pageBlock>    
</apex:page>

closed as unclear what you're asking by Martin Lezer, Mohith Shrivastava, Santanu Boral, Brian Mansfield, Adam Spriggs Mar 30 '17 at 16:14

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

2

Most likely you are not able to access the apex:pageblocktable.

That's because, Id's in Salesforce are auto-generated for visualforce components.

To access components in jQuery, one of the easiest method is to use ends with selector.

Try following code.

$("[id$='DataTableBlock1']").DataTable();

Note: Try using HTML table instead of apex:pageBlockTable as the datatable's styling might get messed up.

Not the answer you're looking for? Browse other questions tagged or ask your own question.