Default table style is not loading in my laravel project
I am using laravel and the default table style with dataTables.net is not working
<!DOCTYPE html>
<html>
<head>
<title>Datatables Server Side Processing in Laravel</title>
<!--Data Tables.net-->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<!--CDN J-Query-->
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous">
</script>
<script>
$(document).ready( function () {
$('#myTable').DataTable({
"searching": true
});
} );
</script>
</head>
<body>
<br />
<h3 align="center">Datatables Server Side Processing in Laravel</h3>
<br />
<table id="myTable" class="table border">
<thead>
<tr>
<th><strong>State Name</strong></th>
<th><strong>PC Name</strong></th>
<th><strong>Winning Party</strong></th>
<th><strong>Total Marks</strong></th>
<th><strong>Rank</strong></th>
</tr>
</thead>
<tbody>
<!#foreach($lok2014all as $winner)
<tr>
<td>{{ $winner->statename}}</td>
<td>{{ $winner->pcname}}</td>
<td>{{ $winner->party}}</td>
<td>{{ $winner->total}}</td>
<td>{{ $winner->rank}}</td>
</tr>
#endforeach
</tbody>
</table>
</body>
</html>
The table is not having any style. No pagination links, not search box no show entries. NO border/format for my table
Related
I am trying to save the searched data into PDF.I used It with help of JS .I am trying to achieve it by any of the two function mentioned in script.both of the function are not working. Kindly help me
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<meta name="description" content="" />
<meta name="classification" content="" />
<title>Geochronology Asset Management System | Add Sample</title>
<!-- BOOTSTRAP CORE STYLE -->
<link href="assets/css/bootstrap.css" rel="stylesheet" />
<script>
$(document).ready(function(e){
$("#pdf").click(function(e){
$("#tablepdf").tableExport({
type:'pdf',
escape:'false'
});
});
});
</script>
</head>
<body>
<h2>Export Data to pdf with PHP and MySQL</h2>
<button type="submit" id="pdf" onclick="makepdf()" class="btn btn-info">Export to pdf</button>
<script>
function makepdf(){
var printme=document.getElementByid('tablepdf');
var wme=window.open("","","width:700,height:900");
wme.document.write(printme.outerHTML);
wme.document.close();
wme.focus();
wme.print();
wme.close();
}
</script>
<table id="tablepdf" class="table table-striped table-bordered">
<tr>
<th>Name</th>
<th>Gender</th>
<th>Age</th>
<th>Designation</th>
<th>Address</th>
</tr>
<tr>
<th>Name</th>
<th>Gender</th>
<th>Age</th>
<th>Designation</th>
<th>Address</th>
</tr>
<tr>
<th>Name</th>
<th>Gender</th>
<th>Age</th>
<th>Designation</th>
<th>Address</th>
</tr>
<tr>
<th>Name</th>
<th>Gender</th>
<th>Age</th>
<th>Designation</th>
<th>Address</th>
</tr>
</table>
</div>
</body>
<!-- FOOTER SECTION END-->
<!-- JAVASCRIPT FILES PLACED AT THE BOTTOM TO REDUCE THE LOADING TIME -->
<!-- CORE JQUERY -->
<script src="assets/js/jquery-1.10.2.js"></script>
<script src="assets/js/tableExport.js"></script>
<script src="assets/js/jquery.base64.js"></script>
<!-- BOOTSTRAP SCRIPTS -->
<script src="assets/js/bootstrap.js"></script>
<!-- CUSTOM SCRIPTS -->
<script src="assets/js/custom.js"></script>
<!-- For PDF-->
<script src="assets/js/jspdf/jspdf.js"></script>
<script src="assets/js/jspdf/libs/sprintf.js"></script>
<script src="assets/js/jspdf/libs/base64.js"></script><!-- This templates was made by Colorlib (https://colorlib.com) -->
</html>
My button does not seems to work after click.It does not give any reaction.Kindly guide me whether my library file are correct or not
I am trying to convert the table data into pdf using jquery.it is not working .When I click on the button it does not convert.It appears that the submit button is not at all working
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<meta name="description" content="" />
<meta name="classification" content="" />
<title>Geochronology Asset Management System | Add Sample</title>
<!-- BOOTSTRAP CORE STYLE -->
<link href="assets/css/bootstrap.css" rel="stylesheet" />
<script>
$(document).ready(function(e){
console.log("test")
$("#pdf1").click(function(e){
$("#tablepdf").tableExport({
type:'pdf',
escape:'false'
});
});
});
</script>
</head>
<body>
<h2>Export Data to pdf with PHP and MySQL</h2>
<button id="pdf1" class="btn btn-info">Export to pdf</button>
<table id="tablepdf" class="table table-striped table-bordered">
<tr>
<th>Name</th>
<th>Gender</th>
<th>Age</th>
<th>Designation</th>
<th>Address</th>
</tr>
<tr>
<th>Name</th>
<th>Gender</th>
<th>Age</th>
<th>Designation</th>
<th>Address</th>
</tr>
<tr>
<th>Name</th>
<th>Gender</th>
<th>Age</th>
<th>Designation</th>
<th>Address</th>
</tr>
<tr>
<th>Name</th>
<th>Gender</th>
<th>Age</th>
<th>Designation</th>
<th>Address</th>
</tr>
</table>
</div>
</body>
<!-- FOOTER SECTION END-->
<!-- JAVASCRIPT FILES PLACED AT THE BOTTOM TO REDUCE THE LOADING TIME -->
<!-- CORE JQUERY -->
<script src="assets/js/jquery-1.10.2.js"></script>
<script src="assets/js/tableExport.js"></script>
<script src="assets/js/jquery.base64.js"></script>
<!-- BOOTSTRAP SCRIPTS -->
<script src="assets/js/bootstrap.js"></script>
<!-- For PDF-->
<script src="assets/js/jspdf/jspdf.js"></script>
<script src="assets/js/jspdf/libs/sprintf.js"></script>
<script src="assets/js/jspdf/libs/base64.js"></script><!-- This templates was made by Colorlib (https://colorlib.com) -->
<!-- CUSTOM SCRIPTS -->
<script src="assets/js/custom.js"></script>
</html>
can anyone suggest me what is wrong in my code,I have included all library function .Is there any problem with sequence of the library files ??
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test</title>
<!-- Scripts -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="//cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready( function () {
$('#item_list').DataTable();
});
</script>
<!-- Styles -->
<link href="/metronic/assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="//cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table class="table table-striped" id="item_list">
<thead class="thead-dark">
<tr>
<th class="all">Position</th>
<th class="all">Name</th>
<th class="all">Club</th>
<th class="all">Value</th>
<th class="all">Points</th>
<th class="all">Add</th>
</tr>
</thead>
<tbody>
<tr>
<td>S</td>
<td><a data-id="88" class="player-info">Andreas Cornelius</a></td>
<td>Atalanta</td>
<td>4.50</td>
<td>0</td>
<td><a class="btn-sm btn btn-success" href="http://127.0.0.1:8019/my-team">Add</a></td>
</tr>
<tr>
<td>G</td>
<td><a data-id="1190" class="player-info">Etrit Berisha</a></td>
<td>Atalanta</td>
<td>4.50</td>
<td>11</td>
<td><a class="btn-sm btn btn-success" href="http://127.0.0.1:8019/my-team">Add</a></td>
</tr>
<tr>
<td>G</td>
<td><a data-id="1191" class="player-info">Marco Carnesecchi</a></td>
<td>Atalanta</td>
<td>4.50</td>
<td>0</td>
<td><a class="btn-sm btn btn-success" href="http://127.0.0.1:8019/my-team">Add</a></td>
</tr>
</tbody>
</table>
</body>
</html>
I am getting this error:
Uncaught TypeError: $(...).DataTable is not a function
This is my code:
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="//cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready( function () {
$('#item_list').DataTable();
});
</script>
I literally removed all the other scripts I had to make sure there are no conflicts or anything. jQuery works otherwise, so this works for example:
$(document).ready( function () {
console.log('What is going on');
});
Does anyone have any idea whatsoever what might be the problem here?
I got the latest version of both jQuery and Datatables from their respective CDNs.
This is the actual table:
<table class="table table-striped" id="item_list">
<thead class="thead-dark">
<tr>
<th class="all">Position</th>
<th class="all">Name</th>
<th class="all">Club</th>
<th class="all">Value</th>
<th class="all">Points</th>
</tr>
</thead>
<tbody>
#foreach($players as $player)
<tr data-id="{{ $player['id'] }}">
<td>{{ $player['position']['short_name'] }}</td>
<td>{{ $player->name }}</td>
<td>{{ $player['club']['name'] }}</td>
<td>{{ $player->value }}</td>
<td>{{ $player->season_score }}</td>
</tr>
#endforeach
</tbody>
</table>
All the rows have correct data displayed, it's just Datatables that's the problem.
I'm new to Bootstrap and Ember. I'm trying to generate a responsive table using Ember.js.
The problem is that when my application is running if I change the browswer's size to an small one, I don't see the horizontal scroll at the table as expected.
However if I save the web page and open it from disk, then it works ok. Very odd :)
I'm pasting my page code here in case it helps. It's a simple example I'm using to learn.
Thanks in advance.
Cheers!!
Gonzalo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
<!-- Bootstrap -->
<link href="libs/bootstrap-3.3.2-dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<script type="text/x-handlebars">
<h2>Registro de llamadas</h2>
{{outlet}}
</script>
<script type="text/x-handlebars" id="index">
<div class="container">
<div class="table-responsive">
<table class="table">
<th>
Número
</th>
<th>
Nombre
</th>
<th>
Asunto
</th>
{{#each item in model}}
<tr>
<td>
{{#link-to 'editarLlamada' item}}Editar{{/link-to}}
</td>
<td>
{{item.number}}
</td>
<td>
{{item.name}}
</td>
<td>
{{item.subject}}
</td>
</tr>
{{/each}}
</table>
</div>
</div>
<button {{action 'nuevallamada'}}>Nueva llamada</button>
</script>
<script type="text/x-handlebars" id="nuevallamada">
<div class='container'>
<p>Acá ingreso la nueva llamada</p>
{{input type="text" value=number}}
{{input type="text" value=name}}
{{input type="text" value=subject}}
<button {{action 'guardarllamada'}}>Guardar</button>
</div>
</script>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="libs/bootstrap-3.3.2-dist/js/bootstrap.min.js"></script>
<!-- <script src="js/libs/jquery-1.10.2.js"></script> -->
<script src="js/libs/ember-template-compiler-1.10.0.js"></script>
<script src="js/libs/ember-1.10.0.debug.js"></script>
<script src="js/libs/ember-data.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers/nuevallamada-controller.js"></script>
<script src="js/routes/nuevallamada-route.js"></script>
<script src="js/routes/editarllamada-route.js"></script>
<script src="js/routes/index-route.js"></script>
</body>
</html>
According to bootstrap, the table structure should be like below
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>header1</th>
<th>header2</th>
</tr>
</thead>
</tbody>
<tr>
<td>value 1</td>
<td>value 2</td>
</tr>
</tbody>
</table>
</div>
For more reference follow Bootstrap Responsive Table
i am using datatable to search the table content.but datatable cant work in my html code
I want to introduce filtering and sorting functionality to my table .all the table library included in the html script
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
<!-- jQuery -->
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
<!-- DataTables -->
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
</head>
<body>
<script type="text/javascript">
$('table').dataTable();
</script>
<table style="margin-top:100px">
<thead>
<tr class='header'>
<th>Name</th>
<th>Party</th>
<th>Constituency</th>
<th>Gender</th>
</tr>
</thead>
<tbody><tr>
<th>pom</th>
<th>1</th>
<th>bachni</th>
<th>male</th>
</tr>
<tr>
<th>santosh</th>
<th>2</th>
<th>bachni</th>
<th>male</th>
</tr>
<tr>
<th>deepak</th>
<th>3</th>
<th>bachni</th>
<th>male</th>
</tr>
<tr>
<th>sudhir</th>
<th>1</th>
<th>savarde</th>
<th>male</th>
</tr>
</tbody>
</table>
</body>
</html>
Since you've placed your script before your DOM, you need to put your jQuery code inside DOM ready handler $(document).ready(function() {...}); or shorter form $(function(){...}):
This step is used to make sure all of your DOM elements have been loaded to the page before executing your jQuery code:
$(function() {
$('table').dataTable();
});
Try this code now work fine:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
<!-- jQuery -->
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
<!-- DataTables -->
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
</head>
<body>
<script type="text/javascript">
$('table').dataTable();
</script>
<table style="margin-top:100px" class="table table-striped table-bordered datatable dataTable">
<thead>
<tr class='header'>
<th>Name</th>
<th>Party</th>
<th>Constituency</th>
<th>Gender</th>
</tr>
</thead>
<tbody><tr>
<th>pom</th>
<th>1</th>
<th>bachni</th>
<th>male</th>
</tr>
<tr>
<th>santosh</th>
<th>2</th>
<th>bachni</th>
<th>male</th>
</tr>
<tr>
<th>deepak</th>
<th>3</th>
<th>bachni</th>
<th>male</th>
</tr>
<tr>
<th>sudhir</th>
<th>1</th>
<th>savarde</th>
<th>male</th>
</tr>
</tbody>
</table>
<script>
$(function() {
$('table').dataTable();
});
</script>
</body>
</html>
please check this fiddle