Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery Datatable first time load issue
    primarykey
    data
    text
    <p>When I am trying to use JQuery datatable, for the first load, the datatable css is not loading properly,</p> <p>but for subsequent loads, the table loads properly.</p> <p><img src="https://i.stack.imgur.com/3CLex.jpg" alt="enter image description here"></p> <p>The following is the html</p> <p><strong>HTML:</strong></p> <pre><code>&lt;table id="test"&gt; &lt;thead id="testhead"&gt; &lt;tr&gt; &lt;th&gt;Created Date &lt;/th&gt; &lt;th&gt;Source Name &lt;/th&gt; &lt;th&gt;Description &lt;/th&gt; &lt;/thead&gt; &lt;tbody id="testbody"&gt;&lt;/tbody&gt; &lt;/table&gt; </code></pre> <p><strong>Javascript</strong></p> <p>In Javascript, I am trying to create and dynamically and append it to $("testhead") and $("testbody") respectively.</p> <pre><code> dwr.util.removeAllRows("testhead"); dwr.util.removeAllRows("testbody"); var table_header = $("#testhead"); var header_row = $("&lt;tr&gt;&lt;/tr&gt;"); /** * * Populate table header */ var cell = $("&lt;th&gt;&lt;/th&gt;"); cell.text("Created Date"); header_row.append(cell); cell = $("&lt;th&gt;&lt;/th&gt;"); cell.text("Source Name"); header_row.append(cell); table_header.append(header_row); cell = $("&lt;th&gt;&lt;/th&gt;"); cell.text("Description"); header_row.append(cell); table_header.append(header_row); var table_body = $("#testbody"); for ( var i = 0; i &lt; data.length; i++) { var row = $("&lt;tr&gt;&lt;/tr&gt;"); var cell = $("&lt;td&gt;&lt;/td&gt;"); cell.text(data[i].createdDate.getDay() + "-" + data[i].createdDate.getMonth() + "-" + data[i].createdDate.getFullYear()); row.append(cell); cell = $("&lt;td&gt;&lt;/td&gt;"); cell.text(data[i].sourceName); row.append(cell); cell = $("&lt;td&gt;&lt;/td&gt;"); cell.text(data[i].description); row.append(cell); } $('#test').dataTable({ "bJQueryUI":true, "aLengthMenu": [[10,25,50,100,-1], [10,25,50,100,"All"]], "iDisplayLength" : 10, "bPaginate" :true, "bAutoWidth":true, "bRetrieve":true, "aoColumns":[ {"sTitle":"Created Date","bSearchable" : true,"bSortable" :true}, {"sTitle":"Source Name","bSearchable" : true,"bSortable" :true}, {"sTitle":"Description","bSearchable" : true,"bSortable" :true}, ], "sDom":'&lt;"H"lfr&gt;t&lt;"F"ip&gt;&lt;"clear"&gt;', "sPaginationType":"full_numbers", "sPageButton":"paginate_button", "sPageButtonStaticDisbaled":"paginate_button" }) $("#test").css("width","100%"); $("#test").dataTable().fnDraw(); showDiv('results'); </code></pre> <p>In the first call to the function, my table is not getting rendered properly.</p> <p>Could someone help me regarding this issue?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload