Quantcast
Channel: DataTables 1.9 — DataTables forums
Viewing all articles
Browse latest Browse all 1816

How to preserve the rows of the datatable even after page refresh.

$
0
0
Hi all,
I need to know a way in which we can retain the added rows of the datatable even after page refresh.I tried using "bStateSave": true but that doesnt seem to work.Following is my html page and the debugger link is http://debug.datatables.net/ezezog



<html><head>
<script type="text/javascript" src="C:/Users/212/Documents/JQUERY/DataTables-1.9.4/DataTables-1.9.4/media/js/jquery.js"></script>
<script type="text/javascript" src="C:/Users/212/Documents/JQUERY/DataTables-1.9.4/DataTables-1.9.4/media/js/jquery.dataTables.js"></script>
<style type="text/css" title="currentStyle"> @import "C:/Users/212/Documents/JQUERY/DataTables-1.9.4/DataTables-1.9.4/media/css/demo_table.css";</style>
<script>
$(document).ready( function () { $('#table_id').dataTable({"bStateSave": true});
$('#submit').click(addrow);
} );

function addrow() {
$('#table_id').dataTable().fnAddData( [
$('#empid').val(),
$('#fname').val(),
$('#lname').val()
] );

}
</script>
</head>
<body>
EmpId:<input type="text" id="empid" name="empid"><br>
First name: <input type="text" id="fname" name="fname"><br>
Last name: <input type="text" id="lname" name="lname"><br>


<input type="button" value="add" id="submit" />
<table id="table_id" class="display"> <thead>
<tr> <th>emp ID</th> <th>First Name</th> <th>Last Name</th> </tr> </thead>
<tbody>

</tbody></table>
</body>
</html>

Can anyone provide me suggestions in this regard,Thank you in advance.

Viewing all articles
Browse latest Browse all 1816

Trending Articles