admin管理员组文章数量:1400375
I used following javascript to get row index. By using this the ID(table header) always starts with 1 in case next 10 values are selected in every page.i need to show next 10 as 11 to 20. Thank you very much..
$(document).ready(function() {
$('#example').dataTable( {
"processing": true,
"serverSide": true,
"ajax": "scripts/server_processing.php",
"aoColumns": [
{
"sTitle": "ID"},
{
"sTitle": "E Mail"},
{
"sTitle": "FirstName"},
{
"sTitle": "LastName"},
{
"sTitle": "Company"},
{
"sTitle": "Course"},
{
"sTitle": "Module"},
{
"sTitle": "Completions"},
{
"sTitle": "First"},
{
"sTitle": "Last",
"sClass": "center"},
{
"sTitle": "Lowest"},
{
"sTitle": "Highest",
"sClass": "center"},
// {
// "sTitle": "#"},
],
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var index = iDisplayIndex +1;
$('td:eq(1)',nRow).html(index);
return nRow;
}
});
});
I used following javascript to get row index. By using this the ID(table header) always starts with 1 in case next 10 values are selected in every page.i need to show next 10 as 11 to 20. Thank you very much..
$(document).ready(function() {
$('#example').dataTable( {
"processing": true,
"serverSide": true,
"ajax": "scripts/server_processing.php",
"aoColumns": [
{
"sTitle": "ID"},
{
"sTitle": "E Mail"},
{
"sTitle": "FirstName"},
{
"sTitle": "LastName"},
{
"sTitle": "Company"},
{
"sTitle": "Course"},
{
"sTitle": "Module"},
{
"sTitle": "Completions"},
{
"sTitle": "First"},
{
"sTitle": "Last",
"sClass": "center"},
{
"sTitle": "Lowest"},
{
"sTitle": "Highest",
"sClass": "center"},
// {
// "sTitle": "#"},
],
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var index = iDisplayIndex +1;
$('td:eq(1)',nRow).html(index);
return nRow;
}
});
});
Share
Improve this question
asked Jul 29, 2015 at 10:37
Dim236Dim236
311 gold badge1 silver badge3 bronze badges
1
- 2 refer this link stackoverflow./questions/6871198/… – madhu Commented Jul 29, 2015 at 10:42
1 Answer
Reset to default 3EDIT:
Check out this link Datatables-addrow and code is here:
var t = $('#example').DataTable( {
"columnDefs": [ {
"searchable": false,
"orderable": false,
"targets": 0
} ],
"order": [[ 1, 'asc' ]]
} );
t.on( 'order.dt search.dt', function () {
t.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
cell.innerHTML = i+1;
} );
} ).draw();
For getting index in jquery :
$('#example tbody').on( 'click', 'tr', function () {
alert( 'Row index: '+table.row( this ).index() );
} );
For more information visit Datatables
本文标签: javascriptHow to get row index in DatatablesStack Overflow
版权声明:本文标题:javascript - How to get row index in Datatables? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744188408a2594401.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论