0

I am trying to use bootstrap datatables with JSF. I am able to do so. However, the only issue is - When the webpage loads first time then datatable elements such column visibility button, pager, row selection etc don't appear. However, when I refresh the page then these elements get appeared. If I navigate to another page then they disappear again. I have to refresh again to load the elements page. I am trying to debug the issue. However, I couldn't find it out. Can anyone suggest me what could be the possible problem and how can I solve this issue?

$(document).ready(function () {
    $('#bigTable').DataTable(
            {
                "scrollX": true,
                    dom: 'Bfrtip',
                lengthMenu: [
                    [2, 5, 10, -1],
                    ['2 rows', '5 rows', '10 rows', 'Show all']
                ],
                buttons: [
                    'colvis',
                    'pageLength',
                    'csv',
                    'excel'
                ]
            });
});
                            <table id="bigTable" class="table table-striped" style="width:100%">
                                <thead>
                                    <tr class="theme-bg-gray">
                                        <th>Car ID</th>
                                        <th>Car Model</th>
                                        <th>Car Company</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <ui:repeat value="#{car.data}" var="car" varStatus="status">
                                        <tr>
                                            <td> 
                                                <h:outputText value="#{car.id}"/></td>
                                            <td><h:outputText value="#{car.model}"/></td>
                                            <td><h:outputText value="#{car.company}"/></td>
                                        </tr>
                                    </ui:repeat>
                                </tbody>
                            </table>

ow I can solve it?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • Hi @Pratyush Agnihotri, can you share [jsfiddle](http://jsfiddle.net/) link, where we can execute the same – yash Sep 07 '18 at 15:48
  • Possible duplicate of [PrimeFaces DataTables not working](https://stackoverflow.com/questions/27330294/primefaces-datatables-not-working) – yash Sep 07 '18 at 15:50
  • Why not use Bootsfaces? – Jasper de Vries Sep 07 '18 at 17:56
  • If you are using navigation with ajax, send a redirect as explained in [JSF Navigation with Ajax](https://stackoverflow.com/questions/5406855/jsf-navigation-with-ajax) – శ్రీ Sep 10 '18 at 16:56

0 Answers0