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
Nagma KhanNagma Khan 

how to seach in the datatable on the visualfroce page ?

hi everyone

Please support me that i have seen , how to search in  the datatable on the visualfroce page ??



Please support me


Thanks

Nagma
Amit Chaudhary 8Amit Chaudhary 8
Please check below post i hope that will help you
1) http://ohotech.com/2015/05/sortingpagination-and-searching-on-data-table-using-jquery-salesforce.html

Let us know if this will help you
 
Nagma KhanNagma Khan
its not working
Nagma KhanNagma Khan
its thorwing error
Error: paginationjquery Compile Error: Illegal assignment from List<Account> to List<Account> at line 9 column 9
 
Amit Chaudhary 8Amit Chaudhary 8
Look like you created any Apex class with Account Name please delete same or rename same and try above code again
Nagma KhanNagma Khan
i am all ready checkd and i am new so please provide me testable code
Amit
Amit Chaudhary 8Amit Chaudhary 8
Hi Nagma,

Code is working fine. PLease check below screen shot

Apex Class
User-added image
public with sharing class paginationjquery {
    public list<Account> acc{get;set;}
    public paginationjquery() {
        acc=new list<Account>();
        onLoad();
    }
    public void onLoad(){  //This function get called automatically on on load
 
        acc=[Select ID,Name,Phone,AccountNumber,Sic from Account limit 520];
 
 
    }
}



VF page
User-added image
<apex:page showHeader="false" sidebar="false" controller="paginationjquery">
    <apex:form >
    <apex:pageBlock >
    <apex:stylesheet value="https://cdn.datatables.net/1.10.0/css/jquery.dataTables.css"/>
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"/>
    <apex:includeScript value="https://cdn.datatables.net/1.10.0/js/jquery.dataTables.js"/>
 
    <style type="text/css" media="screen">
        table.dataTable.display tbody tr.odd > .sorting_1, table.dataTable.order-column.stripe tbody tr.odd > .sorting_1 {
            background-color: #F1F1F1;
        }
 
    </style>
    <script type="text/javascript" charset="utf8">
    var oTable;
    var currentNumberDisplayed = 5;
 
    $(document).ready(function() {
        $('#load').click( function () {
            var oSettings = oTable.fnSettings();
            currentNumberDisplayed += 5;
            oSettings._iDisplayLength = currentNumberDisplayed;
            oTable.fnDraw();
        });
 
        oTable = $('[id$=testTable]').dataTable({
            "iDisplayLength": 5
        });
    });
 
</script>
 
<apex:dataTable value="{!acc}" var="ac" id="testTable" >
    <apex:column >
        <apex:facet name="header"><apex:outputLabel value="ID" /></apex:facet>
        <apex:outputText value="{!ac.ID}"/>
    </apex:column>
    <apex:column >
        <apex:facet name="header"><apex:outputLabel value="Account Number" /></apex:facet>
        <apex:outputText value="{!ac.AccountNumber}"/>
    </apex:column>
    <apex:column >
        <apex:facet name="header"><apex:outputLabel value="Sic" /></apex:facet>
        <apex:outputText value="{!ac.Sic}"/>
    </apex:column>
    <apex:column >
        <apex:facet name="header"><apex:outputLabel value="Phone" /></apex:facet>
        <apex:outputText value="{!ac.phone}"/>
    </apex:column>
    <apex:column >
        <apex:facet name="header"><apex:outputLabel value="Name" /></apex:facet>
        <apex:outputText value="{!ac.Name}"/>
    </apex:column>
</apex:dataTable>
 
<button type="button" id="load">Load</button>
</apex:pageBlock>
    </apex:form>
</apex:page>



Output
User-added image


NOTE:- Look like you created any class with Account name. Please delete same class and try above code again

 
Nagma KhanNagma Khan
error showing 
Error: Unknown property 'String.ID'
Nagma KhanNagma Khan
Error: paginationjquery Compile Error: Illegal assignment from List<Account> to List<Account> at line 9 column 9     also getting same error