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
Harika B 21Harika B 21 

put data into jquery data table in vf page.

Hi,

I have a table like below
 
<table id="applyFilterTable" class="table table-bordered table-condensed table-responsive" cellspacing="0" width="100%" />


I have called the table to show jquery data table and it is working as long as i dont put data into it.

I am trying to add data in multiple ways see the code below.
function rebuildTable_applyFilterTable(data) {
         console.log('inside table'+data[0].EID__c);
         var dataset = [];
         for(var i=0;i<data.length;i++){
             var ds = [];
             ds.SID = data[i].EID__c;
             ds.Name = data[i].Name;


             dataset.push(ds);
         }
        j$('[id$="applyFilterTable"]').DataTable({
            //"data" : dataset,
            "scrollY": "260px",
            "scrollCollapse": true,
            "paging": true,
            "searching": true,
            "ordering": true,
            "info": true,
            "dom": 'Bfrtip',
            "destroy" : true,
            "buttons": [
                'copy',
                {extend: 'csvHtml5',title: 'Criteria export'},
                {extend: 'excelHtml5',title: 'Criteria export'},
                {extend: 'pdfHtml5',title: 'Criteria export'},
                'print'
            ],
            "columns": [
                        { title: "EID",data:dataset.EID},
                        { title: "Name",data:dataset.Name}

                    ]
        } );
    }


my data set variable has data in it.
​1)i tried data:dataset which is throwing me the following error.
DataTables warning: table id=applyFilterTable - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4


2)if i add the above code of adding data along with title it is not at all showing and not even throwing any errors.

is there a way that my page will not fail. all i need is how to add data

 
Raj VakatiRaj Vakati
Hi Harika , 
Please refer this post where they explained step by step

http://sfdcsrini.blogspot.com/2016/04/jquery-data-tables-in-visualforce-pages.html
https://www.verticalcoder.com/2014/11/21/datatables-in-visualforce-part-1/
https://datatables.net/forums/discussion/31312/salesforce-visualforce-page-using-jquery-data-table-and-freezing-first-column-not-working
Harika B 21Harika B 21
Hi Raj,

I am asking a specific question and i am using remote action to get the data as i need to show more than 1k records on the page and the page cannot be read only.
Raj VakatiRaj Vakati
  • It's not ideal/recommended Approach, in my opinion, to do with RemoteAction. I will suggest using apex controller to get the data and pass it the page. 
  • The response of the remote call has a maximum size of 15 MB. You may be able to show more than 1000 records or may not depends on the data you are fetching.
  • I will recommend yo use apex class to fetch the data 
Harika B 21Harika B 21
Hi Raj,

It is not ideal i agree with you on that, but it is what my user wants. And i use apex class as i wrote my remote action in the class. as you must know you cannot use table and apex:repeat to show more than 1000 records in editable page. The only way you can do that is using remote action and read only method. 

I am 100% sure this is the only i can give what my user wants. I need help in putting data into table not to berate me for using the method.
Raj VakatiRaj Vakati
Agree! Do you want to show all 1000 records in the same page?  If not implement pagination with edit options.
Harika B 21Harika B 21
Hi raj,

I have more than 1k records. it range from <1k to 3k records. jquery data table will have its own pagination and it also helps with export. And they want to export all 3k records at once. if i use custom pagination it is not possible.