Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to apply datatables in AdminLTE? Is it already built in or not? #817

Closed
andyhughes73 opened this issue Nov 30, 2015 · 3 comments
Closed

Comments

@andyhughes73
Copy link

I am trying to apply the DataTables styling to my existing tables. I just want to check, is this functionality already built into the template and active, or do I need to manually include the DataTables CSS and JS files?

I can't see any reference to tables in the app or demo js files.

@condor-bird
Copy link

For datatables need to connect the appropriate styles and scripts.
Example:

CSS file:

`

`

JavaScript file:
<script src="../../plugins/datatables/jquery.dataTables.min.js"></script>
<script src="../../plugins/datatables/dataTables.bootstrap.min.js"></script>

For the table must specify an identifier.

<table id="example" class="table table-bordered table-hover">

 </table>

Use the function for the table:

<script>
 $(function () {
$("#example").DataTable();
});
</script>

@andyhughes73
Copy link
Author

So you mean all tables would need to have the same ID = example?

What about if there are two tables on the same page? I thought you weren't supposed to have more than one ID reference on a page?

@condor-bird
Copy link

I meant other. No, identifier must be unique within a one page. If you use the ID, then each table must have a unique identifier is

<table id="example1" class="table table-bordered table-hover">

 </table>

<table id="example2" class="table table-bordered table-hover">

 </table>
 $(function () {
$("#example1, #example2").DataTable();
});

Or use class:

<table class="datatables">

 </table>
 $(function () {
$(".datatables").DataTable();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants