将行号列添加到jquery数据表 [英] Add row number column to jquery datatables

查看:115
本文介绍了将行号列添加到jquery数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要jQuery数据表在第一列中自动创建行数列,如VB中的datagrid。



看起来像这样:





<任何人都知道如何做到这一点?

解决方案

您只需在aoColumns中定义一个空列。



然后在fnRowCallback函数中,您只需编辑您喜欢的列。每次创建新行时,都会运行此回调。



如果您的第一列具有行号,您可以在fnRowCallback中执行此操作:

  var index = iDisplayIndex +1; 
$('td:eq(0)',nRow).html(index);
return nRow;


I want jQuery datatables to automatically create row number column in the first column like datagrid in VB.

It looks like this:

Anyone knows how to do this?

解决方案

You just define an empty column in aoColumns.

Then in fnRowCallback function you just edit the column how you like. This callback is run every time new row is created.

Basicly if your first column has the row number, you could just do this in fnRowCallback:

var index = iDisplayIndex +1;
$('td:eq(0)',nRow).html(index);
return nRow;

这篇关于将行号列添加到jquery数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆